14 of 15 people found the following review helpful
Comprehensive jQuery guide - a must have
, October 21, 2007
This book is a must have for anyone that is serious about effectively leveraging jQuery in their applications. While the API is very simple, it is also extremely robust and powerful. Even when you think you have a good grasp on how things work, reading a manual like this points out all the little facets that you didn't know existed; whether it be optional method arguments or miscellaneous selectors, you probably aren't writing code as effectively as you could be, and you can't do that until you have at least a general understanding of all the features that jQuery makes available.
One of the great things that this book does, which is rare for an API-style book, is to explain, when possible, what the jQuery API is using behind the scenes to access and traverse the document object model. For instance, it explains that the getElementsByTagName() is used to filter tag-based selectors and that getElementById() is used to filter id-based selectors. While this might not seem important to understand, and after all, the whole point of encapsulation is so that you don't NEED to understand, it can become very useful in terms of optimization. For example, $( "#pagetitle" ) is going to be faster than $( "h1#pagetitle" ) since it can use the direct ID access rather than tag-based filtering. Also, $( "h2.title" ) is going to be faster than $( ".title" ) since it can use the tag-based filtering and not have to iterate over every DOM element looking for a particular class.
In addition to covering the full jQuery API, this book also contains a cursory exploration of the architecture and authoring of custom plug-ins. While the book thoroughly covers basic plug-in authoring, I wish that they had covered some more complex stuff; but, at the same time I think that that probably would be more appropriate for a plug-in based book rather than a general reference manual such as this one.
After discussing plug-in architecture, this book also explores two popular jQuery plug-ins: Dimensions and Form. The dimensions plug-in enhances the built-in height() and width() object methods that already exist. It also introduces a host of other methods that allow developers to find the dimensions and position of elements with the conditional incorporation of various CSS box model properties. The Form plug-in contains many methods that make it super easy to submit a form using AJAX, including many utility methods that assist in the serialization and accessing of form data.
The book does a good job of explaining how the individual Dimensions methods work, especially the height and width related calculations. The position related methods, while explained in depth, left me confused; the demo HTML used in the chapter is explicitly incomplete and this makes it difficult to visualize where the calculated numbers are coming from. It wasn't until I went to the demo site ([...]) that the calculations became clear. Even then, however, you can see that as much as the jQuery plug-ins try to encapsulate the cross-browser issues, there are still problems to be found. For example, calling $('div.dim-outer').offset() returned a LEFT value of 580 in FireFox 2.0 and a LEFT value of 1116 in Internet Explorer 6.0.
The book does a good job of explaining how the individual Form plug-in methods work. And, while I am not one who does a lot of AJAX form submission, I can see how using this plug-in would make that a painless process. Regardless, this plug-in also contains some great utility functions that allow you to grab form data at any given time. This can be useful for partial form updates such as the common two-selected-related scenario. My one gripe with this section is the same issue I have throughout the reference manual: callback arguments are not explained very well. With the form submission process, there are two callbacks available - beforeSubmit and success. Both methods are explained in natural language terms, but only the beforeSubmit method gets a code sample explanation (seven pages after it was explained in english). I don't know about you, but seeing a snippet of code is 10 times more clear than the equivalent natural language description.
This is very nit-picky, but as much as I loved this book, there were a few things that were not perfect; while the majority of the selectors are thoroughly explained, the big exception is the Form selectors. I have gone over this section several times and I just can't quite figure out what it means. The big problem is that unlike the rest of the book, the form selectors have no code samples; it's just be a list of input types, but not listed in any meaningful way. This section feels like an afterthought in the book.
I also felt that some of the callback methods could have been better explained. Most of the jQuery callback methods have arguments passed to them, but unless they were used in the examples, they were not defined as part of the callback function definition. I would rather have seen every argument explicitly defined, whether it was used or not, so that we as developers could see what our options were.
The only other problem with this book is that the jQuery technology is evolving so fast that the most recent release of jQuery (v.1.2.1 at the time of this writing) already has things that are not covered in this book. Not only that, a few of the things that are covered in this book, namely the XPath style selectors, are no longer supported by the core jQuery API (but rather though small plug-ins).
Help other customers find the most helpful reviews
Was this review helpful to you?