laktek / jQuery-Smart-Auto-Complete

AutoComplete plugin with smart defaults and flexibility to customize
http://laktek.com/2011/03/03/introducing-jquery-smart-autocomplete/
248 stars 34 forks source link

Check for multiple instances on one element (problem!) #23

Open skorth opened 12 years ago

skorth commented 12 years ago

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 :-)

skorth commented 12 years ago

Mh, sorry. Even this doens't work propper :-(