jQuery Plugin
Upcoming SlideShare
Loading in...5
×
 

jQuery Plugin

on

  • 945 views

This was my presentation at Silicon Valley Code Camp 09. The material can be downloaded from : http://my/personal/rbiggs/Blog/default.aspx

This was my presentation at Silicon Valley Code Camp 09. The material can be downloaded from : http://my/personal/rbiggs/Blog/default.aspx

Statistics

Views

Total Views
945
Views on SlideShare
932
Embed Views
13

Actions

Likes
1
Downloads
8
Comments
0

2 Embeds 13

http://localhost 11
http://www.udemy.com 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

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 Plugin jQuery Plugin Presentation Transcript

    • jQuery Plugins
      • Authoring Code for Reuse
    • Modularization
      • Write once, throw it away.
      • Write once use it again.
      • Initial cost in time to implement, savings realized later.
    • jQuery Integration
      • Attach it directly to the jQuery object.
      • $.plugIn1 = function() {
        • console.log("This is plugin ONE!");
        • };
      • Put your code inside a jQuery closure:
      • (function($) {
      • // Define method here.
      • $.plugIn2 = function() {
      • console.log("Plugin TWO is working!");
      • };
      • })(jQuery);
      • Use jQuery’s extend method:
      • $.fn.extend({
      • plugIn4 : function() {
        • this.plugIn4.number = 1;
          • return this.each(function(){
        • console.log("This is element number: "
        • + $.fn.plugIn4.number );
      • $.fn.plugIn4.number += 1;
      • });
      • }
      • });
      • We can enclose the extended plugin in a jQuery closure and give it options:
      • (function($) {
        • $.fn.extend({
        • hilite : function(options) {
            • return this.each(function() {
        • // Define what you want to do with your items.
      • });
      • }
        • });
      • })(jQuery);
      • Attaching code directly to the jQuery object is the most limited type of plugin. This is a very poor choice.
      • Using a jQuery closure provides namespacing, but lacks built-in jQuery functionality. This is appropriate for many types of widgets
      • Using the jQuery extend method gives your plugin all the built-in power that native jQuery methods have.
    • We’re Hiring!
      • Bee Tan, Hiring Manager
      • 510 307-8225