Archive for September, 2007

Namespace Your Events

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…)

Animated Scrolling with jQuery 1.2

Sunday, September 16th, 2007

A few weeks ago I wrote about how to use jQuery and a couple modules from the Interface plugin suite to automatically have same-page links scroll to their target location when clicked (Animated Scrolling for Same-Page Links). Well, now that jQuery 1.2 is out, and I’ve successfully upgraded this site to it without a hitch, we can do the same thing with jQuery core alone.

Here is what the code looks like with the minor change:
(more…)

Upgrading to jQuery 1.2

Thursday, September 13th, 2007

As I’m sure most of you have already heard, the jQuery Project Team has just released a major new version (1.2) of our beloved JavaScript Library. Hat’s off to John Resig and the gang for another spectacular release!

I’m going to upgrade this site to the new version this weekend. On a typical site, I’d feel pretty confident about moving forward without any hiccups—especially after hearing all the success stories on the jQuery discussion list. But since the nature of this site is to demonstrate techniques used with jQuery, its use of the library is probably more comprehensive (for lack of a better word) than most. Therefore, I want to be extra careful. My simple plan for the transition to 1.2 is described below, along with some discussion of the API changes, in the off chance that it helps others who wish to upgrade with caution.
(more…)