Fixed bug with selecting multi suggest item with the enter key.

No longer does selecting an item with the enter key repopulate
the drop down.

Change-Id: I372f319ba41c348d667eb3a60e2f8a7c5efad235
This commit is contained in:
Rob Moen 2012-08-23 15:43:06 -07:00
parent f8a43c8776
commit fa3d364f3c

View file

@ -104,7 +104,9 @@
inputTimer = setTimeout( function() {
var txt = $input.val().toLowerCase();
if ( txt !== '' ) {
// Check for query in cache object.
// Be sure that input has changed.
if ( txt !== currentInput ) {
// Build fresh if query not in cache.
if (
!( txt in cache ) &&
typeof options.input === 'function'
@ -114,20 +116,19 @@
cache[txt] = params;
} );
} else {
// Rebuild from cache only if query has changed.
// This prevents disrupting the menu on keypress.
if ( txt !== currentInput ) {
// Rebuild from cache.
build( cache[txt] );
}
}
// Set current input.
currentInput = txt;
} else {
// No Text, close.
if ( visible ) {
close();
}
}
// Set current input.
currentInput = txt;
}, 250 );
}
// Opens the MultiSuggest dropdown.
@ -136,9 +137,8 @@
// Call input method if cached value is stale
if (
$input.val() !== '' &&
$input.val() !== currentInput
$input.val().toLowerCase() !== currentInput
) {
currentInput = $input.val();
onInput();
} else {
// Show if there are suggestions.
@ -241,9 +241,7 @@
// Bind target input events
$input.on( {
// Handle any change to the input.
'keyup change cut paste': onInput,
// Handle arrow up and down keys.
'keydown': function( e ) {
'keydown cut paste': function( e ) {
var $item,
$items = $multiSuggest
.find( '.' + options.prefix + '-suggest-item' ),
@ -292,6 +290,8 @@
return;
}
}
// Handle normal input.
onInput();
},
'focus': function(){
focused = true;