#6015 closed bug (notabug)
autocomplete "change" handler gets old value
Reported by: | mu_mind | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | ui.autocomplete | Version: | 1.8.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If I click on a value in the dropdown list, the "change" handler seems to be executed before .val() changes.
For example, if I set up a text box:
<input type="text" id="text"></input>
and then execute:
$("#text").autocomplete({source: ["foo", "bar"]}); $("#text").change(function () {alert($(this).val());});
and finally type "fo" and click "foo" in the dropdown, I get an alert box that says "fo".
I've tested this in both Chromium 7.0.499.0 and Firefox 3.6.8 on Ubuntu.
Note: See
TracTickets for help on using
tickets.
The change event is completely outside the scope of the autocomplete plugin. The behavior you're seeing is correct, since you're blurring the text field while it says "fo" in order to click the item from the menu. You can use the autocompletechange event to figure out the actual value that was selected.