I created a button
element with an onclick
handler using the following method:
domConstruct.create('button', {
...
value: someValue,
onclick: this.onBtnClick
});
The onBtnClick
method uses the value of the button element, and also calls another function:
onBtnClick: function() {
var someVar = this.value // This button element's value property
this.someFunc(someVar);
}
someFunc: function(arg) {
...
}
When executing onclick
, it gives an error:
Uncaught TypeError: this.someFunc is not a function at HTMLButtonElement.onBtnClick
However, the button element's value could be correctly fetched by this.value
. So it looks like in the onBtnClick
method the this
keyword only refers to the button element instead of the entire widget. Is there anyway to use both the button element's value as well as this.someFunc
in onBtnClick
?