• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
jQuery BootCamp : Extending jQuery with Custom Plugins
 

jQuery BootCamp : Extending jQuery with Custom Plugins

on

  • 1,243 views

 

Statistics

Views

Total Views
1,243
Views on SlideShare
1,143
Embed Views
100

Actions

Likes
0
Downloads
7
Comments
0

2 Embeds 100

http://www.scoop.it 99
http://webcache.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    jQuery BootCamp : Extending jQuery with Custom Plugins jQuery BootCamp : Extending jQuery with Custom Plugins Presentation Transcript

    • #7 Day #7 Extending jQuery with custom plugins Wildan Maulana wildan.m@openthinklabs.com http://workshop.openthinklabs.com
    • Overview● Why to extend jQuery with custom code● The rules for effectively extending jQuery● Writing custom utility functions● Writing custom wrapper methods
    • Why extend?
    • The jQuery plugin authoring guidelines● Extending jQuery takes one of two forms: ● Utility functions defined directly on $ (an alias for jQuery) ● Methods to operate on a jQuery wrapped set (so- called jQuery commands)● Naming files and functions● Beware the $● Taming complex parameter lists●
    • The jQuery plugin authoring guidelines Naming files and functions● Prefix the filename with jquery.● Follow that with the name of the plugin.● Conclude with .js. jquery.openthinklabs.utils.js
    • The jQuery plugin authoring guidelines Beware the $ (function($){ // // Plugin definition goes here // })(jQuery);
    • The jQuery plugin authoring guidelines Taming complex parameter listsfunction complex(p1,p2,p3,p4,p5,p6,p7) { complex(valueA,null,null,null,null,null,valueB); complex(valueA,null,valueC,valueD,null,null,valueB); complex(valueA, {p7: valueB}); complex(valueA, { p3: valueC, p4: valueD, p7: valueB });
    • The jQuery plugin authoring guidelines Taming complex parameter listsfunction complex(p1,p2,p3,p4,p5,p6,p7) { function complex(p1,options) { complex(p1,options) var settings = $.extend({ option1: defaultValue1, option2: defaultValue2, option3: defaultValue3, option4: defaultValue4, option5: defaultValue5, option6: defaultValue6 },options||{}); // remainder of function... }
    • Writing custom utility functions$.say = function(what) { alert(I say +what); } jQuery.say = function(what) { alert(I say +what); } (function($){ $.say = function(what) { alert(I say +what); } })(jQuery);
    • Q&A
    • Reference● Jquery in Action, Bear Bibeault, Yehuda Katz, Manning