Opened 8 years ago

Closed 8 years ago

#7874 closed bug (notabug)

onchange doesn't work when using mouse to select an item

Reported by: jamesgu Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.autocomplete Version: 1.8.16
Keywords: Cc:
Blocked by: Blocking:

Description

I add autocomplete on an input field and it has "onchange" event.

When I use arrow key to move to a select item and press "Enter" to select it, the "onchange" event is fired correctly.

When I use mouse to click on an item to select it, the "onchange" event is fired twice before the input value is changed (One of it should be caused by the focus is move out of the input field). The autocomplete should fire "onchange" event after setting the value on input field but it didn't do it.

Environment, I didn't find the version in drop down list. jquery-1.4.4.js jQuery Autocomplete plugin 1.1 IE 8.

Suggestion fix: jquery.autocomplete.js, line 602. add logic to fire "onchange" event if the value is changed.

}).click(function(event) {

$(target(event)).addClass(CLASSES.ACTIVE); var beforeValue = input.value; select(); var afterValue = input.value; if (beforeValue != afterValue) {

input.fireEvent("onchange");

}

TODO provide option to avoid setting focus again after selection? useful for cleanup-on-focus input.focus();

Change History (1)

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

Resolution: invalid
Status: newclosed

That's not jQuery UI.

Note: See TracTickets for help on using tickets.