I went back to scratch and did up a simplified rewrite of my plugin. I haven't found the problem with the actual plugin yet, but at least now I know how the architecture is *supposed* to work.
Chaining doesn't come into it (as suggested by Sean), but the test code at http://fatdog.com/multiPluginTest/testMultiPlugins.html does demonstrate, as stated by Michael, that each invocation of a function/plugin instantiates a new copy of the function/plugin object, complete with a fresh slate of local variables. Amazing that I didn't know that! :-) It was good to go back to zero, so that I now understand this important concept. Now on to figuring out why my *real* plugin (not that much more complicated than this simple test prototype) isn't working ... Howard On Nov 24, 4:20 pm, howardk <[EMAIL PROTECTED]> wrote: > Michael and Sean, > Thanks to both of you. I think I'll take you up on your offer of > posting some (simplified) code. Sometime tomorrow if I can find the > time for it ... > Thanks again, > Howard > > On Nov 24, 3:49 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote: > > > You may be worried about a problem that doesn't exist. Every time you call a > > function, JavaScript creates a new, unique set of local variables for that > > invocation of the function. It doesn't reuse the same function invocation > > and its local variables over and over again. > > > Now, you *could* write code that would get you in trouble here. For example, > > you could use global variables instead of local variables in your function, > > and those would get overwritten as you might expect. > > > But normal JavaScript behavior does exactly what you want here. This is true > > for plugin methods just like any other functions. > > > As Shawn suggested, if you have trouble with a specific bit of code, post a > > link to it and someone can take a look at it. > > > -Mike > > > > From: howardk > > > > Is there a way of instantiating multiple instances of a > > > plugin on the same page? > > > > What I have essentially is an animated effects plugin, and I > > > want to be able to invoke separate instantiations of it, > > > doing something like the following: > > > > <script> > > > $( '#effect_1' ).animEffect( { name: 'jumper', color: > > > 'ff0000', fps: > > > 30 } ); > > > $( '#effect_2' ).animEffect( { name: 'round-the-moon', color: > > > 'ffff00', fps: 40 } ); > > > </script> > > > > <div id='effect_1'></div> > > > <div id='effect_2'></div> > > > > I'm still fairly new to javascript. As far as I can tell > > > though, it looks like it can't be done, since as far as I can > > > see, each plugin invocation is really calling the same > > > function object over and over again (thereby overwriting > > > whatever instance or local variables might have been set in a > > > prior invocation). > > > > Is this correct? Is there a way of doing this, or am I out of luck? > > > Howard