We all love auto complete. It makes our lives a little less complicated and classy. I decided to (as a complimantry to my new JS beloved framework) to use the JQuery autocomplete plugin, problems began when I needed to use dynamically added text fields with autocomplete. Since the plugin assumes that you use a single and unique DOM ID, was unable to setup the autocomplete feature to newly dynamic fields.
One solution was to add the fields by javascript and Dom manipulation, but I prefered to use a partial in order to keep the code simple and Rubish. The other solution was to add a javascript script tag in the end of the partial which traverses the DOM and adds a unique and random id, and of course setting the auto complete feature for each one of them.
Bottom line, it is working and even working well, but I would like to hear new ideas if anyone has.
Over and out.
I'm about to attempt the same type of thing. Care to share the code you used?
ReplyDeleteSorry, but the project was delieverd a while ago and i can't access the code anymore.
ReplyDeletefrom what i remember it's pretty simple.
i created a js function that runs right after the dom insert of the new field is being added,
This function traverses the DOM and identifies all the fields from the kind that we added (class="autocomplete_field" for example) and enables the JQuery autocomplete for each of them.
got it?
Yes; this is precisely what I was going to try. Glad to hear you were successful with it (and that it was easy :)
ReplyDeleteGreat,
ReplyDeletedon't forget to come back and post a link to your own post.