I add my input fields dynamically to the dom, or if there is already data i have multiple fields given. All of them using the same class. If i now bind the plugin on these elements it cause problems. I like the pattern to use 'data' to check if the plugin already exists on an element.
I add my input fields dynamically to the dom, or if there is already data i have multiple fields given. All of them using the same class. If i now bind the plugin on these elements it cause problems. I like the pattern to use 'data' to check if the plugin already exists on an element.
I did it like this...
return this.each(function(i) { if($(this).data("smart-autocomplete")){ return something.... } else { init events..... } }
Would be cool to have this, especially for event driven plugins :-)