I have a form with a variable number of autocomplete fields that use the same select list. These fields are added and removed as needed. Whenever a parameter on the page is changed, I (try to) update the list for all the fields by first calling unbind()
then autocomplete()
with a new parameter added to the url.
$('input.foo').unbind().autocomplete(url?new_param=bar);
The problem is that unbind() does not seem to be unbinding. When I type in the input field, it fires off the entire history of autocomplete events.
I also tried flushCache to no avail.
How do I clear out the old events?
Thanks.
$(target).autocomplete("destroy");
Try this
$ ('input.foo').unbind('.autocomplete').autocomplete ('url?new_param=bar') ;
The autocomplete plugin adds a function called unautocomplete() to remove autocomplete() from fields that have it, so it should work if change your code to:
$('input.foo').unautocomplete().autocomplete('url?new_param=bar');
This unautocomplete() function should remove all of the old events.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With