Re: Object-oriented plugins?
Providing the method name as the first parameter is a bit awkward,
perhaps looking at the alternatives would help:
Add namespaces to jQuery. This isn't very jQuery-like. Example: $
(el).tabs.add(url, label).show();
Add a new jQuery method for every plugin instance method. This
pollutes the jQuery namespace, so this should only be done when it
really makes sense. Example: $(el).addTab(url, label);
Use events. You can bind custom events in a namespace and then have
users interact with your plugin by triggering those events. Example: $
(el).trigger('add.tabs', url, label);
There may be other approaches as well.
The jQuery UI approach allows plugins to expose as many methods as
they want while only using one method in the jQuery namespace.