Hi,
I often need to create single events that are not needed after they have run once. The way I do is something like:
A.prototype.someMethod = function () {
var me = this;
this.onWindowMouseUpFunction = function () {
me.onWindowMouseUp.apply(me, arguments);
};
window.addEventListener('mouseup', this.onWindowMouseUpFunction, false);
}
A.prototype.onWindowMouseUp = function () {
window.removeEventListener('mouseup', this.onWindowMouseUpFunction, false);
}
However, since the event logic is split into two methods and I cannot use anonymous functions and instead have to assign the function to a variable, I have begun to think that there must be a better way of doing this, right?