Posted By

nikefido on 05/12/11


Tagged

plugin jquery


Versions (?)

jQuery plugin template - enhanced


 / Published in: jQuery
 

  1. (function($){
  2.  
  3. var environment = {};
  4.  
  5. var methods = {
  6. init:function(options) {
  7.  
  8. var options = $.extend({}, options);
  9.  
  10. return this.each(function() {
  11.  
  12. });
  13.  
  14. }
  15. };
  16.  
  17. $.fn.nameOfTemplate = function(method){
  18. if ( methods[method] ) {
  19. return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
  20. } else if ( typeof method === 'object' || ! method ) {
  21. return methods.init.apply( this, arguments );
  22. } else {
  23. $.error( 'Method ' + method + ' does not exist on jQuery.nameOfTemplate' );
  24. }
  25. };
  26. })(jQuery);

Report this snippet  

You need to login to post a comment.