Brandon's Archive
Thursday, September 20th, 2007
A common pattern in jQuery plugin development is the need to undo what the plugin has done. This is usually handled through a method prefixed with “un”. Another common pattern is the use of anonymous functions for event handlers. Unbinding events is easy with jQuery but unbinding a single event handler requires the use of a named function. jQuery 1.2 now provides another option for binding and unbinding events: event namespaces.
(more…)
Posted in Events, Intermediate, Plugins, jQuery | 8 Comments »
Wednesday, March 21st, 2007
Sometimes it is very convenient to store information on an element by using custom properties (DOM Expandos). For example, I use DOM Expandos in my Mouse Wheel plugin to store an array of handler methods (_mwHandlers) along with a method (_mwHandler) to call all those handlers when the mouse wheel is used. Storing these methods on the element allows me to write less code, and manage scope easier. It also gives me a function reference for easy removal when needed.
Now, what if I needed to select all elements that have a mouse wheel handler on them?
(more…)
Posted in Advanced, DOM Traversing, jQuery | 4 Comments »
Wednesday, January 31st, 2007
Need to clone an element and its events? Sure, you could rebind the events after doing the clone, but that wouldn’t be very DRY now, would it? Introducing Copy Events, a new plugin for jQuery.
(more…)
Posted in DOM Modification, Events, Intermediate, Plugins, jQuery | 3 Comments »