Skip to content
This repository

afterUpdateElement on ENTER press #17

Open
wants to merge 1 commit into from

1 participant

Brian McQuay
Brian McQuay

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

Showing 1 unique commit by 1 author.

Oct 06, 2010
Brian McQuay adding afterUpdate call if Enter is pressed 887b161
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. 6  src/controls.js
6  src/controls.js
@@ -129,7 +129,11 @@ Autocompleter.Base = Class.create({
129 129
       switch(event.keyCode) {
130 130
        case Event.KEY_TAB:
131 131
        case Event.KEY_RETURN:
132  
-         this.selectEntry();
  132
+         if (this.options.afterUpdateElement) {
  133
+           this.options.afterUpdateElement(this.element, this.element);
  134
+         } else {
  135
+           this.selectEntry();
  136
+         }
133 137
          Event.stop(event);
134 138
        case Event.KEY_ESC:
135 139
          this.hide();
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.