harvesthq / chosen

Deprecated - Chosen is a library for making long, unwieldy select boxes more friendly.
http://harvesthq.github.io/chosen/
Other
21.85k stars 4.11k forks source link

Success callback is rebound on every keyup, causing a recursive call to itself #665

Closed skwp closed 12 years ago

skwp commented 12 years ago

If you put a console.log inside the success callback (options.success), you'll notice that you're rebinding the callback on every keyup event. Which means on the first autocomplete, your callback is called once, second time twice, then three times, etc.

Besides being possibly a performance issue, what happens due to this is some fairly strange behavior such as if you delete an autocompleted term, sometimes the word you typed magically retypes itself, or other such bugs (believe to be related, but not 100% sure)

In either case, the success callback should only be bound a single time, when the box is initialized. The only reason you can't do that is because it currently relies on the value of the box in order to put it back after clearing it. The box seems to be cleared by select.trigger("liszt:update") - not sure why that clears the box, or why we can't just leave the search term in the box if nothing is autcompleted.

Will hopefully have a patch or at least something to look at soon..but I wanted to put this up here for discussion to see if anyone has dealt with this at all. Thanks!

skwp commented 12 years ago

wrong project sorry!