If I'm calling a function from an onclick event, I'd usually use this
to access the element that fired the event. But if I'm using a dojo require, then this
is not accessible within the require.
HTML:
<button id = "someButton"> Click Me </button>
Javascript:
require (["dojo/on", "dojo/dom"], function (on, dom) {
var button = dom.byId ("someButton");
on (button, "click", doSomething);
});
function doSomething () {
console.log (this.id); // someButton
require (["dojo/dom-class"], function (domClass) {
console.log (this.id); // undefined
domClass.add (this, "clicked");
});
}
How would I access this
inside the require?