Code snippet for jQuery plugin

Heres just a quick code snippet for netbeans that you can use for creating a new jQiery plugin.

To use this go into options/editor/code templates/JavaScript, create a new code template assigning a shortcut to it (mine is jp as from jQuery plugin ;), and then paste the code below.

(function($){
            $.${c1} = function( options) {
              
            }  
            $.fn.${c1} = function( options ) {
              // ensure options are there
              options = options || {};
                this.each(function() {
                new jQuery.${c1}( options );
              });
                        // don't break chain
              return this;
            }
          })(jQuery);

The assumption is that the code will have the same name for the object and for the function used. It will automatically set the cursor in the function name and place it in the two spots. It's really easy to customize it, and create your own templates that said just want to add that Netbeans is really awesome...

Comments

No comments yet, you can be the first one to comment one the subject, to do that use the form below.

Comment on the subject

The email address and name is required but the email will not be published. You can use textile markup. Also gravatars are used if they exist.

In the secret type in the month and year without any separator. If January 2008 then 12008. It's a simple antispam protection.