The problem is, you're not referencing
this
within the
addEvt
function; you're referencing it from the handler for the
onclick
event raised on the canvas.
Within that event handler, you seem to be expecting
this
to point to both the element that was clicked, and the object the event handler was added from.
You'll need to capture the outer
this
reference. You'll also need to fix up your
$(this)
references, and fix the syntax error in your function.
addEvt: function(){
const me = this;
document.getElementById('canvas'+id).onclick = function(e){
const el = $(e.target);
const args = {};
var id = el.attr('data-root');
args['page'] = el.attr('data-page');
args['c_id'] = el.attr('data-ole');
args['panel'] = el.attr('data-target');
const text = me.getText(args['page']);
if (text){
args['length'] = text.length;
}
return args;
}
}
Once you've sorted that, you'll need to check your logic. For example, returning an array from the
onclick
event handler isn't going to do what you think it will do.