Adventures in jQuery
The last week or so I've had the pleasure of working deeply with jQuery.
And I mean that, it's been a pleasure.
Once you get used to the 'style' of how it works, it makes sense and has a consistent coding experience.
I've worked mainly with the core and the ui.jquery libraries, with fileupload thrown in.
In the mix is also
I've got jQuery adding and removing custom DOM elements on the fly, while updating information on the server, uploading and deleting images and also maintaining the structure of the form so that when it is submitted in the usual "post" manner, the server knows what to do with the data it receives.
So all in all I've had a good experience with it.
Things it has helped me understand is the use of "anonymous Functions" (I think that is what they are called)
EG:
now the "hide" method will accept an argument of a function that it will call when it has completed. Commonly called a "callback", so i we had a function like this:
To use an anonymous function to do the same thing, this is what you would do:
You can also do this in Flex.
eg:
rather than:
One thing that works, but somehow feels wrong, is that the anonymous functions have direct access to the variables declared in the calling function.
eg:
{
var someString = "bob";
$("#myelement").hide( function(){ alert( someString ); } );
}
So all in all I've enjoyed getting to know jQuery, and suspect it's the beginning of a beautiful friendship!
...but, I still prefer Flex!
