Depends how your plugin is set up.

If you didn't implement the chaining techniques, then chances are you only have one instance. But if you did implement chaining, you *should* have multiple instances.

Do you have something like this line in your plugin?

return $(this).each( function () {
  // plugin code goes here....
});

If you can post your code, we can help more. OR, you can go to the #jquery channel on IRC and use a pastie (www.pastie.org) to get some more interactive help...

Hope that helps some.

Shawn

howardk wrote:
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

Reply via email to