Your SlideShare is downloading. ×
Growing jQuery
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Growing jQuery

2,595
views

Published on

How to create plugins and extend jQuery.

How to create plugins and extend jQuery.


0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,595
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
96
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. GROWING JQUERY How to extend jQuery for your needs
  • 2. jQuery! Plugins World Domination
  • 3. Attack of the Libraries!
  • 4. Mad Scientist
  • 5. Separating the Process Selection Action jQuery Selection Action  $(‚#id‛,‚div.class‛)  $(…).show()
  • 6. Cut & Paste
  • 7. Plugins!
  • 8. Easy as baking cookies! “How can I limit the user to only select up to 3 checkboxes?” Boring Method Way Cooler Method $(quot;input:checkboxquot;).click(function(){ jQuery.fn.limit = function(n) { var boxes = $(‚input:checkbox‛); var self = this; if(boxes.filter(‚:checked‛) return this.click(function(){ .length < 3) { return self this.checked = true; .filter(quot;:checkedquot;).length<=n; } }); }); }; $(quot;input:checkboxquot;).limit(3);
  • 9. Cute Plugins $.fn.vals = function(){ var v=[]; this.each(function(){ v.push( $(this).val() ); }); return v; }); $.fn.zebra = function(){ return this.filter(‚:odd‛) .addClass(‚odd‛).end(); };
  • 10. Extending jQuery jQuery.expr[‘:’].mod = ‚i%(m[3]-0)==0‛; jQuery.expr[‘:’].date = ‚/^s*d{2}/d{2}/d{4}s*$/ .test( jQuery(a).text() || ‚‛ )‛;
  • 11. Simplicity  $(…).idTabs(2);  $(…).idTabs(‚default‛)  $(…).idTabs(function(id){ alert(‚Clicked ‛+id); });  $(…).idTabs({ start: ‚default‛, change: ‚false‛ });
  • 12. Questions? Sean Catchpole sean@sunsean.com