Skip to main content

Search and Top Navigation

#6015 closed bug (notabug)

Opened September 02, 2010 02:24PM UTC

Closed September 02, 2010 02:54PM UTC

Last modified October 11, 2012 09:15PM UTC

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:

#!js
  $("#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.

Attachments (0)
Change History (2)

Changed September 02, 2010 02:54PM UTC by scottgonzalez comment:1

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.

Changed October 11, 2012 09:15PM UTC by scottgonzalez comment:2

milestone: TBD

Milestone TBD deleted