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

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -