Created
June 16, 2015 09:32
-
-
Save kedramon/5909cac6d2f37d086952 to your computer and use it in GitHub Desktop.
Handler for the "onkeydown" event to submit the autocomplete input by hitting the Enter key, also input must have a 'auto-submit' class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function ($) { | |
| Drupal.jsAC.prototype.onkeydown = function (input, e) { | |
| if (!e) { | |
| e = window.event; | |
| } | |
| switch (e.keyCode) { | |
| case 13: // Enter. | |
| if ($(input).hasClass('auto-submit')) { | |
| this.hidePopup(e.keyCode); | |
| input.form.submit(); | |
| } | |
| return true; | |
| case 40: // down arrow. | |
| this.selectDown(); | |
| return false; | |
| case 38: // up arrow. | |
| this.selectUp(); | |
| return false; | |
| default: // All other keys. | |
| return true; | |
| } | |
| }; | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment