javascript - extend function in jquery -


i new query , trying understand below plugin function doing, not understanding.

var pluginname = 'widgets';  function plugin(element, options) {     /**      * variables.      **/     this.obj = $(element);     this.o = $.extend({}, $.fn[pluginname].defaults, options);     this.objid = this.obj.attr('id');     this.pwctrls = '.jarviswidget-ctrls'     this.widget = this.obj.find(this.o.widgets);     this.toggleclass = this.o.toggleclass.split('|'); } 

i thankful if 1 great in jquery explain step step.

thank in advance.

regards, mona

jquery's $.extend merges contents of 2 or more objects first object.

in other words, takes object default settings plugin, gets object passed in options, , joins them options overwrite defaults.

example

var defaults = {     setting1 : '2',     setting2 : true }  function plugin(options) {     var settings = $.extend({}, defaults, options);      /* settings contain      {         setting1: '2',         setting2: false     }     */ }  plugin({     setting2: false // options, change default settings }); 

the plugin function seems part of sort of widget build plugins, sets few general settings instance.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -