Registration for jQuery Conference 2008 is closed.

jQuery Entries

Tutorials Elsewhere

Friday, November 2nd, 2007

Quite a few jQuery tutorials have been posted around the web recently. It’s always great to see more people not only learning jQuery, but also teaching it to others. Here are just a few that I think could be helpful to readers of Learning jQuery:
(more…)

Thanks for jQuery

Wednesday, October 31st, 2007

Last week I attended The Ajax Experience conference in Boston (no, I didn’t go to a Red Sox game), sponsored by the folks at ajaxian.com The schedule was packed with outstanding presentations. But the highlight of my trip was jQueryCamp07, which was held at Harvard University on Saturday.

Throughout the week I had quite a few opportunities to talk with John Resig, the creator and lead developer of jQuery. But, like the social clod that I am, I forgot to do the one thing that I had set out to do: Thank John Resig, in person, for the jQuery JavaScript Library. It was only after I returned home on Sunday that I realized my oversight. So, at the risk of sounding sappy, I figure I ought to write in a public forum what I had meant to say face to face.
(more…)

A Plugin Development Pattern

Tuesday, October 30th, 2007

I’ve been developing jQuery plugins for quite a while now, and I’ve become rather comfortable with a particular style of plugin development for my scripts. This article is meant to share the pattern that I’ve found especially useful for plugin authoring. It assumes you already have an understanding of plugin development for jQuery; if you’re a novice plugin author, please review the jQuery Authoring Guidelines first.

There are a few requirements that I feel this pattern handles nicely:

  1. Claim only a single name in the jQuery namespace
  2. Accept an options argument to control plugin behavior
  3. Provide public access to default plugin settings
  4. Provide public access to secondary functions (as applicable)
  5. Keep private functions private
  6. Support the Metadata Plugin

I’ll cover these requirements one by one, and as we work through them we’ll build a simple plugin which highlights text.
(more…)

Improved Animated Scrolling Script for Same-Page Links

Saturday, October 20th, 2007

After posting the last entry on animated scrolling with jQuery 1.2, I realized that I had left out an important piece of code. Actually, I didn't discover it until someone notified me that another page on the site was broken. Can you spot the problem(s)? [Note: the problem is not in line 3. The syntax highlighter just can't handle the regular expression with two slashes in it ("//") and is incorrectly treating them as a comment mark.] See the answer below the code.

JavaScript:
  1. $(document).ready(function(){
  2.   $('a[href*=#]').click(function() {
  3.     if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
  4.     && location.hostname == this.hostname) {
  5.       var $target = $(this.hash);
  6.       $target = $target.length && $target
  7.       || $('[name=' + this.hash.slice(1) +']');
  8.       if ($target.length) {
  9.         var targetOffset = $target.offset().top;
  10.         $('html,body')
  11.         .animate({scrollTop: targetOffset}, 1000);
  12.        return false;
  13.       }
  14.     }
  15.   });
  16. });

(more...)

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