If we use the proper KendoUI syntax for calling an event, on an object instance...
This in the called method is clobbered....
If we use the kendo.Class.extend method of making a Class, it's the same deal...
Any way out of this scope clobbering? It's also a bit mystifying that it's a "feature" since we get the DOM payload through "e"
I'd like to call this a bug report, when an object method is called with an event handler, the object container should be set as this/context.
<
a
data-role
=
"button"
data-click
=
"myClass.addToList"
data-mynumber>Add me</
a
>
function
MyClass() {
};
MyClass.prototype.list = [1, 2, 3];
MyClass.prototype.addToList =
function
(e) {
// 'this' is clobbered
this
.list.push(e.sender.context.dataSet.mynumber);
// list thrown as undefined.
}
var
myClass =
new
MyClass();
Any way out of this scope clobbering? It's also a bit mystifying that it's a "feature" since we get the DOM payload through "e"
I'd like to call this a bug report, when an object method is called with an event handler, the object container should be set as this/context.