Skip to content


Subversion checkout URL

You can clone with
Download ZIP


afterUpdateElement on ENTER press #17

wants to merge 1 commit into from

1 participant


Currently, if no element is selected in Autocomplete it defaults to the first element if a user presses ENTER. This isn't a good default especially when the users passes in an afterUpdateElement function. The user most likely wants to update the contents of a DOM object after an element is selected with the search results. If no element is selected an the user presses enter its more useful to send the text field content to the user defined afterUpdateElement so that the user can do their own custom search against the field rather than assuming the user wants the first element to be selected.

My changes basically allow a user to define their own search function using afterUpdateElement if no element is selected and ENTER is pressed. If the user doesn't pass in an afterUpdateElement the function behaves as it does now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 6, 2010
  1. @onomojo
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/controls.js
6 src/controls.js
@@ -129,7 +129,11 @@ Autocompleter.Base = Class.create({
switch(event.keyCode) {
case Event.KEY_TAB:
case Event.KEY_RETURN:
- this.selectEntry();
+ if (this.options.afterUpdateElement) {
+ this.options.afterUpdateElement(this.element, this.element);
+ } else {
+ this.selectEntry();
+ }
case Event.KEY_ESC:
Something went wrong with that request. Please try again.