4 ms·
You can take a look at the event fixing code here: http://dev.jquery.com/browser/trunk/jquery/src/event.js#L285 http://dev.jquery.com/browser/trunk/jquery/src/e
by jeresig 18y ago
You can take a look at the event fixing code here:
http://dev.jquery.com/browser/trunk/jquery/src/event.js#L285 http://dev.jquery.com/browser/trunk/jquery/src/event.js#L285
There's really not much to it - and it's really not much different from the code that you show above. A lot has changed since 1.3 so if you're still having problems, perhaps its not here and with some other aspect of the event handling code. Any more input would definitely be appreciated.
"I don't like how I have to have a reference to the bound function laying around somewhere so that I can unbind it."
Here are a couple ways to unbind an event handler without needing the original function.
$("div").bind("click", function(){});
// Unbind all bound events
$("div").unbind();
// Unbind all click events
$("div").unbind("click");
$("div").bind("click.tmp", function(){});
// Unbind all click events with the name 'tmp'
$("div").unbind("click.tmp");
The last one is probably what you want.
- sam_in_nyc 18y agoSometime today I'll try to reproduce the conditions. It was definitely event fixing (or something in jQuery) that did it, because even if I cleared out the mousemove function, it would still be laggy. But if I didn't bind it, the lag would go away. You're right, the event namespacing was exactly what I was looking for. BTW, is there a list of "reserved" words in jQuery? For example, jQuery has to store this information somewhere... possibly it gets attached to the DOM element itself. Where does ".data()" live? I often directly access the DOM elements, and want to be sure I don't interfere with jQuery.
- sam_in_nyc 18y agoUpdate: I don't see myself having time to set-up a situation where IE lags... I've got so much stuff on my plate -- trying to launch in a week. Sorry John!
- jeresig 18y agoWe maintain all of the element data (including events, etc.) in an internal data store. We attach a single expando to an element - whose name is randomly generated (this allows jQuery to, not only, co-exist with other libraries but also to coexist with other copies of jQuery, since there'll never be a collision with the name). I hope this helps to clear it up.