don't match again if user input does no change anything
This commit is contained in:
parent
7edd9086e4
commit
482f09afee
1 changed files with 5 additions and 0 deletions
|
@ -13,6 +13,7 @@ c3nav = {
|
|||
|
||||
init_typeahead: function () {
|
||||
c3nav.typeahead_locations = [];
|
||||
c3nav._last_typeahead_words_key = null;
|
||||
$.getJSON('/api/locations/?searchable', function (data) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var location = data[i];
|
||||
|
@ -37,6 +38,7 @@ c3nav = {
|
|||
val = $(this).val(),
|
||||
val_trimmed = $.trim(val),
|
||||
val_words = val_trimmed.toLowerCase().split(/\s+/),
|
||||
val_words_key = ' '.join(val_words),
|
||||
$autocomplete = $('#autocomplete');
|
||||
$(this).parent().removeClass('selected').toggleClass('empty', (val === ''));
|
||||
|
||||
|
@ -44,6 +46,9 @@ c3nav = {
|
|||
$autocomplete.html('');
|
||||
return;
|
||||
}
|
||||
if (val_words_key === c3nav._last_typeahead_words_key) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < c3nav.typeahead_locations.length; i++) {
|
||||
var location = c3nav.typeahead_locations[i],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue