Hey everyone. I'm trying to create multiple instances of a widget I'm creating but the variables that should be contained in each instance is being shared across all of them. widget: ;(function($,window,document,undefined){ var $this, $el, $url, $btnClose; $.widget("dev.smt",{ options: { windowID:"", title:"", winTrans:50 }, _create:function(){ $this=this, $el=$this.element; var $markup="\ <div class='smt_window' id='"+$this.options.windowID+"' style='display:none;'>\ <a id='"+$this.options.windowID+"_btnClose' href='#'><img class='close' src='img/close.png'/></a>\ <p class='hdr unSelectable'>"+$this.options.title+"</p>\ </div>"; $("body").append($markup); $win=$("#"+$this.options.windowID); $btnClose=$($this.options.windowID+"_btnClose"); $el.click(function(e){$this.display(true); }); $btnClose.click(function(e){$this.display(false);}); }, display:function(aDisplay){ if(aDisplay){ this.win.fadeIn(50); } else { this.win.fadeOut(50); } } }); })(jQuery,window,document); ----------------------- elements: $("#SMT_btnUserRegistry").smt({ windowID:"smt_userRegistry", title:"User Registry" }); $("#SMT_btnAnnouncements").smt({ windowID:"smt_announcements", title:"Announcements" }); $("#SMT_btnPictureManager").smt({ windowID:"smt_pictureManager", title:"Picture Manager" }); -------------------------- $this and the other vars that should be local to the function are getting stepped on by each instance created. Still familiarizing myself with plugins and widgets. Any guidance is greatly appreciated.
Figured it out. $this and other vars were global to all instances of the widgets. Brought them down a level and all was fixed.