How can I access the root this
inside the events
property of the Test
object:
"use strict";
var Test = function (element, options) {
};
Test.prototype = {
constructor: Test,
events: {
handleEvent: function (event) {
// this.setup() should point to the Test.prototype.setup property
},
start: function (event) {
}
},
setup: function () {
}
};
After I use the following syntax to add an event listener to an element:
document.getElementById.addEventListener("touchmove", this.events, false);
Where this.events
refers to the Test
object. After I tested it, I have noticed that this
in that case will be the events
object. How can I tweak the code in such way to have the root object available inside the properties of the events
object ?