* @param object event
*/
_keyDown: function(event) {
- if (event.which === 13) {
- if (this._searchInput.parents('.dropdown').data('disableAutoFocus') && this._itemIndex === -1) {
- // allow submitting
+ if (event.which === $.ui.keyCode.ENTER) {
+ var $dropdown = this._searchInput.parents('.dropdown');
+
+ if ($dropdown.data('disableAutoFocus')) {
+ if (this._itemIndex !== -1) {
+ event.preventDefault();
+ }
}
- else {
+ else if ($dropdown.data('preventSubmit') || this._itemIndex !== -1) {
event.preventDefault();
}
}
setTimeout(function() { self._onPaste(); }, 100);
});
}
+
+ // block form submit through [ENTER]
+ this._searchInput.parents('.dropdown').data('preventSubmit', true);
},
/**
*/
_keyDown: function(event) {
// 188 = [,]
- if (event === null || event.which === 188) {
+ if (event === null || event.which === 188 || event.which === $.ui.keyCode.ENTER) {
+ if (event.which === $.ui.keyCode.ENTER && this._search) {
+ if (this._search._itemIndex !== -1) {
+ return false;
+ }
+ }
+
var $value = $.trim(this._searchInput.val());
// read everything left from caret position