Skip to main content

Search and Top Navigation

#11052 reopened feature ()

Opened February 09, 2015 01:48PM UTC

Last modified February 09, 2015 02:51PM UTC

Autocomplete: Trigger change event when return is pressed

Reported by: pl_fidessa Owned by:
Priority: minor Milestone: none
Component: ui.autocomplete Version: 1.11.2
Keywords: Cc:
Blocked by: Blocking:

The change events for the autocomplete widget are subtly different from a plain text box.

A text box raises change events if:

  • the content is changed and focus leaves the control
  • the content is changed and return is pressed (just before the submit event of the form)

The autocomplete control only raises a change event when focus leaves the control.

This can be seen in the following jsfiddle: The bottom div displays the events that are triggered, so just type into a control and press return to see what events are raised.

Note that the behaviour in IE9 seems to be a bit different (although I'd argue still incorrect). As far as I can tell pressing return moves focus away from the control, so you see a submit event for the form, then a change event for the autocomplete control.

What I'd like is for the behaviour of the autocomplete widget to be the same as the text box. i.e. if you change the value then press return (without having focus on the dropdown menu), then a change event is triggered immediately. If that's something you're willing to consider than I can format up a patch and submit a pull request.

Version information:

Tested with:

  • JQuery 2.1.0
  • JQuery 1.11.2 (though the code in the mainline is the same as far as I can tell)
  • Chrome 40.0.2214.111 m on Windows 7 (similar behaviour seen in Firefox, IE9 behaviour differs as described above)

Many thanks,


Attachments (0)
Change History (3)

Changed February 09, 2015 02:09PM UTC by scottgonzalez comment:1

resolution: → notabug
status: newclosed

Changed February 09, 2015 02:23PM UTC by pl_fidessa comment:2

Replying to [comment:1 scott.gonzalez]:

See and #8878.

Hi Scott,

Sorry, I think I've probably used the wrong terminology in my initial report since #8878 seems to specifically be about the native change event vs the autocompletechange event.

I am using the autocompletechange event on the autocomplete widget, and am proposing that you fire an autocompletechange event when return is pressed. I'm not using the native change event for anything on the autocomplete widget.

Do you still consider this to be "notabug"?



Changed February 09, 2015 02:51PM UTC by scottgonzalez comment:3

resolution: notabug
status: closedreopened
summary: autocomplete does not raise a change event when return is pressed.Autocomplete: Trigger change event when return is pressed
type: bugfeature

I'd say this is a feature request, since the intention of the event is pretty clearly documented: "Triggered when the field is blurred, if the value has changed." I'll reopen for others to weigh in.