-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Success callback is rebound on every keyup, causing a recursive call to itself #30
Comments
You can try something like this.
Two things I did:
|
+1 |
jhanggi
added a commit
to jhanggi/ajax-chosen
that referenced
this issue
Jan 14, 2013
Should resolve issue meltingice#30
Closed
jlavallee
pushed a commit
to jlavallee/ajax-chosen
that referenced
this issue
Feb 7, 2013
Should resolve issue meltingice#30
jlavallee
pushed a commit
to jlavallee/ajax-chosen
that referenced
this issue
Feb 7, 2013
Should resolve issue meltingice#30
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is probably not dangerous, but possibly a performance issue and could lead to subtle bugs.
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 autocompleted.
Not sure what to do about this without understanding why the trigger is clearing out the box, but happy to help if someone points me in the right direction. Thanks!
The text was updated successfully, but these errors were encountered: