I don't know what to put in the part in bold to set the click event listener and have it call function4 within the functiontest object. I've tried a bunch of different things and nothing worked. Please help, thanks!
I'm sure I don't understand what you are trying to do at all
but in case that you are asking if it's possible to add event listeners to native JS objects -I'll have to say "not".
Only DOM elements can.
I think the problem is that the value of "this" will vary depending on the context of the function being executed. In the case of a listener, "this" will be the event's target, which in this case will be a DIV element.
What you'll need to do is, outside of the listener callback, save the value of "this" in another variable.
Code:
var that = this;
gebid(this.t).addEventListener('click', function () {
that.uid.function4(that.t);
}, false);
Once you get past that hurdle, you're likely to run into another problem with this line:
Code:
that.uid.function4()
The method "function4" belongs to the that/this object, not to the uid property.
Bookmarks