Jquery set defaults for all instances of a plugin -


Looking at the following plug-ins, how would you set the default for all instances? I would like to do the same as $ .datepicker.setDefaults ().

  (function ($) {$ .fn.borderSwitcher = function (options) {defaults = {borderColor: '$ (this). $ (This). Focus (function () {/ Find a better way to set / limit properties. Var prope = settings.borderStyle + '' settings.borderWidth + '' settings.borderColor; $ (this) .css ('border', props);}); $ (This) .blur (function () {$ (this). CSS ('border', '');}}}}}}}}}}) (jQuery);  

Add them to the jQuery object:

  ( Function ($) {$ .border.switcher.defaults = {// Note: There is no limit here Color: 'black', threshold width: '1px', border style: 'solid'} $ $ Fn.borderSwitcher Set the default for all the new instances $ $ = function (option) {var settings = $ .extend ($ .default, defaults, option); // your rest code}}; // and outside your plugin definition. BorderSwitcher.defaults.borderWidth = '2px'; $ ('.foo'). With borderline (); // 2px $ ('.foo'). Images: '3px'}); // 3px  
with

Comments