Javascript Mootools click event and his caller? -
i have little script:
var moolang = new class({ initialize: function(element) { this.el = $(element); this.el.addevent('click', this.popup); }, popup: function() { //this.id = id of element. } });
and want know "this" in popup function. if try alert(this.el.id) says there no this.el :/
is there way know class adds event?
change attach event callee has proper context. otherwise context of event listener target element.
// change line this.el.addevent('click', this.popup); //to this.el.addevent('click', this.popup.bind(this)); // popup->this ==
jsfiddle here see mootools documentation. binding context of function.
Comments
Post a Comment