jQuery boilerplate


/ Published in: jQuery
Save to your folder(s)

https://github.com/zenorocha/jquery-boilerplate/blob/master/jquery.boilerplate.min.js


Copy this code and paste it in your HTML
  1. ;(function ( $, window, document, undefined ) {
  2.  
  3. var pluginName = 'defaultPluginName',
  4. defaults = {
  5. propertyName: "value"
  6. };
  7.  
  8. function Plugin( element, options ) {
  9. this.element = element;
  10. this.options = $.extend( {}, defaults, options) ;
  11.  
  12. this._defaults = defaults;
  13. this._name = pluginName;
  14.  
  15. this.init();
  16. }
  17.  
  18. Plugin.prototype.init = function () {
  19. // code goes here
  20. };
  21.  
  22. $.fn[pluginName] = function ( options ) {
  23. return this.each(function () {
  24. if (!$.data(this, 'plugin_' + pluginName)) {
  25. $.data(this, 'plugin_' + pluginName, new Plugin( this, options ));
  26. }
  27. });
  28. }
  29.  
  30. })(jQuery, window, document);

URL: http://jqueryboilerplate.com/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.