Once you’ve made a selection, the fun begins – jQuery Fundamentals by Rebecca Murphey

jQuery fun has begun with my reading of jQuery Fundamentals By Rebecca Murphey or it may have been earlier when I’ve been told that jQuery is a monad, or maybe when I found out that JavaScript is a functional, object-oriented language. I can’t claim I know the answer, but I do like activities that let me explore more areas at once. I kept hearing about jQuery here and there and it seems I’ve worked up a real appetite to give it a short try. I’m rather a server-side developer and in the spirit of self-learning I begun reading the book – jQuery Fundamentals that I stumbled upon the other day.

After two three chapters I must admit that the book is well-written, clear and concise. It should be quite an easy affair to read it up at once, but I haven’t done it myself merely for the sake of not spending much time on it while having other assignments awaiting my curiosity.

I had a few JavaScript affairs. It’s been once when I used Greasemonkey to manipulate a page with some JavaScript hacks and now I’m temped to think it’s exactly the exact same sort of exercise, albeit the audience is a bit different. With jQuery scripts in a page, it is really part of the entire page and everybody who visits it will experience its outcome whereas running a script with Greasemonkey is for more advanced users who want to manipulate a page on their own with no benefit to other potential visitors. It should be clear, but I thought I’d dump it here for others to correct my oversight should there be one.

While reading the jQuery Fundamentals I was again exposed to Firebug and its console. I finally found a way to run JavaScript scripts in a sort of JavaScript REPL. It made my day and was very enlightening experience.

With JavaScript, Greasemonkey and Firebug it looks like jQuery allowed me to learn more than a framework to build a highly sophisticated web page, but experience the whole lot of different tools I could be using for other things like website performance tuning and such.

Also, JavaScript is the language of choice in IBM WebSphere Lombardi Edition and makes learning the language the inevitable for mastering the product. I guess I have no choice as to learn JavaScript for my personal and professional benefits and I do believe jQuery can greatly boost the pace (although I don’t claim it may work out for others).

While reading the book I found a mind-blowing return with the JavaScript ternary operator ?: in the Selecting Elements section. I think I would have never done it in Java, but once I saw it in JavaScript I see nothing wrong with it in Java now. You’ve been warned if you’ve ever been thinking about me as a project teammate.

Interesting quotes to remember from the book. Don’t let them be a substitute for the book.

  • The most basic concept of jQuery is to “select some elements and do something with them.”
  • When you make a selection using $(), an object is always returned.
  • Getters return a property of the first selected element; setters set a property on all selected elements.
  • Chaining is extraordinarily powerful, and it’s a feature that many libraries have adapted since it was made popular by jQuery.
  • jQuery “overloads” its methods, so the method used to set a value generally has the same name as the method used to get a value.
  • Setters return a jQuery object, allowing you to continue to call jQuery methods on your selection; getters return whatever they were asked to get, meaning you cannot continue to call jQuery methods on the value returned by the getter.
  • CSS properties that normally include a hyphen need to be camel cased in JavaScript.
  • As a getter, the $.fn.css method is valuable; however, it should generally be avoided as a setter in production-ready code, because you don’t want presentational information in your JavaScript. Instead, write CSS rules for classes that describe the various visual states, and then simply change the class on the element you want to affect.
  • whitespace doesn’t matter in JavaScript, so you should feel free to use it liberally to make your code more legible!
  • Be cautious with traversing long distances in your documents — complex traversal makes it imperative that your document’s structure remain the same, something that’s difficult to guarantee even if you’re the one creating the whole application from server to client.
  • Once you’ve made a selection, the fun begins.

It certainly did. I’ve left the following chapter 4. jQuery Core for the other day. On to some other articles about jQuery to have the newly acquired knowledge to settle down a bit in my mind.

Be Sociable, Share!
This entry was posted in Frameworks.

Leave a Reply

%d bloggers like this: