views:

88

answers:

1

I have a plugin I'm working on that will eventually be used in multiple places on the same page. I have noticed this can lead to issues around not finding the correct one to operate on when the plugin is called. What is the best way to use some sort of context when using this plugin. I have included a context object in my list of options for the plugin, but others such as the datepicker plugin don't require a context object when using them. How do others scope their plugins to avoid this?

+1  A: 

If a plugin is only supposed to work in certain areas of a page I tend set a different CSS class and then allow that plugin to work against elements with that Class.

e.g.

$('.class').plugin();

to work against items like

AutomatedTester