Escolar Documentos
Profissional Documentos
Cultura Documentos
Browser Incompatibilities
Varying Dom/Css implementations Varying event management interfaces Varying feature support
What's jQuery?
Javascript HTML DOM Manipulation library Light weight (~20k compressed) Powerful and extremely practical functionality Easy to learn and intuitive to use Familiar CSS 3 based selector syntax Easy to extend through plug-in API 100's of plug-ins for just about anything Popular and getting more popular all the time
Consistent event context (this = DOM element) Normalized event object to bridge browser diffs
Plug-in API
Very easy, yet powerful API jQuery.fn allows extending of Wrapped Set this context passed as Wrapped Set It's super easy! Result: 100's of plug-ins
Selection of elements
Id ("#id"), Class (".class"), Element ("div") DOM Instance (ctl), jQuery Instance (jCtl) [attribute],>child, descendent,+next,~siblings :first,:last,:not,:even,:odd,:contains,:parent,:empty,:hidden,:visible
http://docs.jquery.com/Selectors
jQuery Utilities
'Static' methods of jQuery object
Provide generic functionality Highly useful operations Defined directly off of the static jQuery object
Highlights
$.ajax, $.post, $.getJson, $.getScript $.ready: Reliable load completion
used extensively for page setup code
$.merge: Extend an array with another $.grep: Filter arrays with function delegates
jQuery Intellisense
Visual Studio 2008 SP1 provides jQuery support
Required to get any Intellisense for jQuery and plug-ins Basic Intellisense support in the box Visual Studio 2010 has native support
Options
Send form data Send an object's data as querystring data Determine how data is parsed on result
Pure AJAX
HTML + JSON JSON JSON
Server Side
JavaScript Serializer (System.Web.Extensions) DataContractJsonSerializer (System.ServiceModel.Web) WCF REST Serivces ASMX ASP.NET AJAX Web Services Third Party Tools
Extensibility of jQuery
Plug-ins and Building ASP.NET controls that use and interact jQuery
A Simple Plug-in
$.fn.pulse = function(time) { if (!time) time = 2000; // this == jQuery object that contains selections this.fadeTo(time,0.30, function() { $(this).fadeTo(time,1); }); return this; // return 'this' to chain } Example: $("#ulList li:even").pulse(1500);
Applies a Pulse effect to the set of matched elements, that fades out to 30% opacity, then fades back into full opacity for the time interval specified.
Keep it consistent
Examine existing Plug-ins Check out jquery.ui
Summary
jQuery is a powerful client side tool Easy to get started with Play with it if you haven't You'll be surprised how much easier Javascript can be with the right tool!
Resources
Download Updated Slides/Code: www.west-wind.com/files/conferences/jquery.zip White Paper www.west-wind.com/presentations/jQuery jQueryControls Documentation: http://www.west-wind.com/westwindwebtoolkit/docs jQuery Cheat Sheet http://labs.impulsestudios.ca/jquery-cheat-sheet Books:
jQuery in Action - http://tinyurl.com/2luw4e jQuery Reference Guide - http://tinyurl.com/2vhcbu Learning jQuery - http://tinyurl.com/2mzv6o