jQuery special events

jQuery special events

I wrote a (rather in-depth) article on jQuery special events recently but forgot to link it in the forums, so I'm going to mention it here. I apologize in advance for its length, but I had a lot to say!

The jQuery special events API is a fairly flexible system by which you can specify bind and unbind hooks as well as default actions for custom events. In using this API, you can create custom events that do more than just execute bound event handlers when triggered—these “special” events can modify the event object passed to event handlers, trigger other entirely different events, or execute complex setup and teardown code when event handlers are bound to or unbound from elements.

Note that this article uses some advanced jQuery techniques and assumes you understand the concepts of custom events and event delegation using bubbling.

Also, because this article is rather long, it has been broken up into sections. I’d recommend reading it in order, one section at a time, because techniques used in subsequent examples often reference those used in previous examples. Also, your brain is going to need a rest here and there, so take it slow.

That being said, I do hope that you stick with it, because there is a lot of useful information here.


- Ben

--
http://bit.ly/benalmandotcom - "There's a Ben Alman jQuery plugin for that"