0

I'm currently writing a plugin and have run into and issue that, from searching stackoverflow, have an idea of what's wrong, but no clue how to code it.

The plugin is really long right now, so I've chopped out only the basics. The plugin works perfectly and loads all default settings for the first object. User settings override the defaults correctly. Everything works with 1 plugin call. As soon as another instance of the plugin is called, the only things that is logged are the settings passed in - all of the other defaults don't even show up.... From looking around I think I need to use the .data ? but I'm not sure and would rather know HOW and WHY this works rather than just copying and pasting code... so hopefully someone can help me out with a clear answer. Below is the trimmed code I have:

;(function($){ 
   jQuery.fn.OnStage=function(options){ 
      var defaults={ ... default settings ... }, 
      o=$.extend(true, {}, defaults, options); return    
this.each(function(){ ....                                                  

Thanks!

Aaron
  • 2,482
  • 1
  • 26
  • 56

1 Answers1

1

Your options object is global .... change to

var  o=$.extend

By having them global they will take on value last set and be the same for all instances

EDIT: adding your settings to element data is a common practice and can help check values easily in console

charlietfl
  • 170,828
  • 13
  • 121
  • 150