jQuery To The Rescue

5 comments | Posted: 1 February 06 in Tutorials, by Cody Lindley

With a flood of JavaScript libraries hitting the web scene, I fear that a gap is being created between JS libraries, and how the libraries themselves interact with the JS events needed to fuel most libraries into action. Typically the events-part of implementing these complex libraries is left up to the person implementing its usage. It’s been my observation that in this regard the pre-packaged scripting solutions are flawed because of the gap between the libraries themselves and how they actually function as it pertains to events. In other words, most of the popular libraries today don’t have a solution for managing how the features of the library should be implemented in consideration of the event model. Ben Nolan obviously agrees, and that is why he created the Behaviour script. The Behaviour script is an attempt to fill the gap associated with most pre-packaged libraries and the event model that invokes the functionality from the libraries. And while it does a great job, I would prefer a total solution instead of using the Behavior script, in addition to a JS library.

Isn’t there a library solution that has accounted for the gap? For a long time a full featured library was not available. That is, in my opinion, until now. It would seem that JQuery has arrived on the javascript library scene to fill the gap. This self proclaimed “Fun” library just might fit the bill, and appropriately so! JQuery actually supplies a total event solution with the library. It deals with the age old issue (addevent();) of manipulating the DOM with multiple events only after the DOM is available. In addition, adding events is built into the library itself. On top of all this the library has a compressed version of the JS code, which saves me time because I don’t have to fix it with JSLint in order to compress it myself. It’s enough to make any client-side code monkey giddy with joy. And did I mention how cool Chainablemethods are!

So in order to demonstrate how simple it is to use JQuery I have setup some examples using Chainablemethods and how one might architect the library in a web page. However, before you jump into my examples you might want to spend some time reading the JQuery Documentation and looking at the tutorial available on the JQuery website.

Make sure to give the very last example a close look. It demonstrates how to use JQuery with functions created outside of the library.

Discuss This Topic

  1. 1 dwntrdr

    Maybe it’s just me, but this doesn’t seem to work in firefox 1.5. I turned on all javascript functionality (i normally have it off) and it still didn’t work. Worked perfectly in IE6 sp2 though.

  2. 2 cody lindley

    @dwntrdr – Worked for me on 3 different computers using firefox 1.5. Worked on OSX with firefox 1.5 too. Anyone else having trouble?

  3. 3 John Resig

    Dwntrdr: If you can pinpoint the problem, that would definitely help. I’ve had about one other person describe a similar situation as yours, but they were unable to duplicate it. Please let me know if you can.

  4. 4 Wesley Walser

    Someone made a JS library chainable? That’s actually one of the more exciting things that I have heard in a while. This looks promising indeed. I come from a Java history, and have really missed the ability to do this in the code (I actually tried it a few times when I started off with JS).

    The example works for me, but I did have some stuff not working for me the other day on a particletree demo while using FF 1.5. No one else seemed to have the same problem.

  5. 5 dwntrdr

    Sorry, took a while to get back to this. I’ve checked and this now works. Not sure if you changed anything but it now works.

    Sorry, I’m like the other person who also couldn’t replicate the problem.


Comments closed after 2 weeks.