From dc0c5048098a180a929b5885526751838b04e2e7 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Mon, 22 Jul 2013 12:58:07 +0000 Subject: [PATCH] don't close menu on enter, but submit input on enter in autocompletemenu if no menu item was selected --- source/Ox.UI/js/Form/Input.js | 12 ++++++++---- source/Ox.UI/js/Menu/Menu.js | 2 -- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/source/Ox.UI/js/Form/Input.js b/source/Ox.UI/js/Form/Input.js index c44bcc95..664c6438 100644 --- a/source/Ox.UI/js/Form/Input.js +++ b/source/Ox.UI/js/Form/Input.js @@ -482,7 +482,7 @@ Ox.Input = function(options, self) { } function constructAutocompleteMenu() { - var menu = Ox.Menu({ + return Ox.Menu({ element: self.$input, id: self.options.id + 'Menu', // fixme: we do this in other places ... are we doing it the same way? var name?, maxWidth: self.options.autocompleteSelectMaxWidth, @@ -490,13 +490,17 @@ Ox.Input = function(options, self) { left: 4, top: 0 } - //size: self.options.size }) .addClass('OxAutocompleteMenu') .bindEvent({ - click: clickMenu + click: clickMenu, + key_enter: function() { + if (self.$autocompleteMenu.is(':visible')) { + self.$autocompleteMenu.hideMenu(); + submit(); + } + } }); - return menu; } function autovalidate() { diff --git a/source/Ox.UI/js/Menu/Menu.js b/source/Ox.UI/js/Menu/Menu.js index fb596dab..1508a2af 100644 --- a/source/Ox.UI/js/Menu/Menu.js +++ b/source/Ox.UI/js/Menu/Menu.js @@ -192,8 +192,6 @@ Ox.Menu = function(options, self) { // called on key.enter if (self.options.selected > -1) { clickItem(self.options.selected); - } else { - that.hideMenu(); } }