Browse Source

Fix bug with search input inside dropdown

pull/1615/head
jlukic 9 years ago
parent
commit
ccf830a600
1 changed files with 13 additions and 12 deletions
  1. 25
      src/definitions/modules/dropdown.js

25
src/definitions/modules/dropdown.js

@ -138,12 +138,9 @@ $.fn.dropdown = function(parameters) {
query = $search.val(); query = $search.val();
module.verbose('Searching for query', query); module.verbose('Searching for query', query);
if(module.is.searchSelection()) {
module.filter(query);
if( module.can.show() ) {
module.show();
}
module.filter(query);
if(module.is.searchSelection() && module.can.show() ) {
module.show();
} }
}, },
@ -405,7 +402,9 @@ $.fn.dropdown = function(parameters) {
; ;
if( module.is.allFiltered() ) { if( module.is.allFiltered() ) {
module.debug('All items filtered, hiding dropdown', searchTerm); module.debug('All items filtered, hiding dropdown', searchTerm);
module.hide();
if(module.is.searchSelection()) {
module.hide();
}
settings.onNoResults.call(element, searchTerm); settings.onNoResults.call(element, searchTerm);
} }
}, },
@ -452,7 +451,9 @@ $.fn.dropdown = function(parameters) {
} }
}, },
input: function(event) { input: function(event) {
module.set.filtered();
if(module.is.searchSelection()) {
module.set.filtered();
}
clearTimeout(module.timer); clearTimeout(module.timer);
module.timer = setTimeout(module.search, settings.delay.search); module.timer = setTimeout(module.search, settings.delay.search);
}, },
@ -753,8 +754,8 @@ $.fn.dropdown = function(parameters) {
return ($choice.data(metadata.text) !== undefined) return ($choice.data(metadata.text) !== undefined)
? $choice.data(metadata.text) ? $choice.data(metadata.text)
: (preserveHTML) : (preserveHTML)
? $choice.html()
: $choice.text()
? $choice.html().trim()
: $choice.text().trim()
; ;
} }
}, },
@ -763,8 +764,8 @@ $.fn.dropdown = function(parameters) {
return ($choice.data(metadata.value) !== undefined) return ($choice.data(metadata.value) !== undefined)
? $choice.data(metadata.value) ? $choice.data(metadata.value)
: (typeof choiceText === 'string') : (typeof choiceText === 'string')
? choiceText.toLowerCase()
: choiceText
? choiceText.toLowerCase().trim()
: choiceText.trim()
; ;
}, },
inputEvent: function() { inputEvent: function() {

Loading…
Cancel
Save