Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#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:


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.

Change History (2)

comment:1 Changed 12 years ago by Scott González

Resolution: invalid
Status: newclosed

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.

comment:2 Changed 10 years ago by Scott González

Milestone: TBD

Milestone TBD deleted

Note: See TracTickets for help on using tickets.