Wednesday, September 12, 2012

writing a jquery plugin


writing a jquery plugin - Google Search

http://docs.jquery.com/Plugins/Authoring



http://www.queness.com/post/112/a-really-simple-jquery-plugin-tutorial
http://www.queness.com/resources/html/simpleplugin/jquery-simple-plugin-queness.html




http://remysharp.com/2010/06/03/signs-of-a-poorly-written-jquery-plugin/





 Data

Often times in plugin development, you may need to maintain state or check if your plugin has already been initialized on a given element. Using jQuery's data method is a great way to keep track of variables on a per element basis. However, rather than keeping track of a bunch of separate data calls with different names, it's best to use a single object literal to house all of your variables, and access that object by a single data namespace.
(function( $ ){

  var methods = {
     init : function( options ) {

       return this.each(function(){
         
         var $this = $(this),
             data = $this.data('tooltip'),
             tooltip = $('<div />', {
               text : $this.attr('title')
             });
         
         // If the plugin hasn't been initialized yet
         if ( ! data ) {
         
           /*
             Do more setup stuff here
           */

           $(this).data('tooltip', {
               target : $this,
               tooltip : tooltip
           });






http://coding.smashingmagazine.com/2011/10/11/essential-jquery-plugin-patterns/
http://www.websanova.com/tutorials/jquery/10-coding-tips-to-write-superior-jquery-plugins



http://www.codeproject.com/Articles/291290/How-To-Write-Plugin-in-jQuery











No comments:

Post a Comment