Initial instincts tell me that adding a listener, either using bind or a straightforward event method to a jQuery set of elements, such as..
$('.className').click(funcName);
Is much more appropriate than using a $.each method to add a listener one by one to the same set, as...
$('.className').each(function(){ $(this).click(funcName); });
But when it comes to plugin development, and you are dealing with the possibility of users calling an instance of your plugin multiple times throughout the lifetime of a page, on page load and through ajax long after page load, is it wrong to apply handlers to each element itself, rather than trying to abstract the handlers to their global class set?
My main question I'm dealing with is "What is the best way to deal with multiple instances of a plugin being called when it comes to event handling? As to reduce the workload?" I know we can bind and unbind, but is there a better way?
EDIT
partial code from plugin construct
init : function(){
this.each(function(opts){
// adding event handlers here removes
// the need to worry about multiple instances
// and duplicate handles over the lifetime of the page
});
// adding 'global' handlers here may/may not be more
// efficient, but adds an issue of multiple instances
return this;
}