Thursday, April 12, 2012

JavaScript events handling

I've made this wonderful plugin: https://github.com/suprMax/Zepto-onPress



Which works perfectly besides one little detail. When I get callback function I need to store it alongside with my real event handler so I can detach it when someone tries to remove event handler and provide me the original callback. So basically I need to be able to store multiple key-value pairs per element where the key supposed to be a function and value is a function too. And I tried to do just that, but right now the script makes



(function(){}).toString() 


internally. Which is not a beast idea since I can remove wrong event handlers because



(function(){}).toString() === (function(){}).toString()


I suppose there is a better way to do just that. Any suggestions are very welcome.





No comments:

Post a Comment