Autocomplete: Clear selectedItem property whenever the user types something. Also updated combobox to clear the select element when clearing the text element. Fixes #5453 - Autocomplete: combobox demo doesn't remove invalid values.

This commit is contained in:
Scott González 2010-07-20 13:24:53 -04:00
parent e4273ff621
commit c2c09e8953
2 changed files with 2 additions and 0 deletions

View File

@ -43,6 +43,7 @@
if (!ui.item) { if (!ui.item) {
// remove invalid value, as it didn't match anything // remove invalid value, as it didn't match anything
$(this).val(""); $(this).val("");
select.val("");
return false; return false;
} }
select.val(ui.item.id); select.val(ui.item.id);

View File

@ -79,6 +79,7 @@ $.widget( "ui.autocomplete", {
self.searching = setTimeout(function() { self.searching = setTimeout(function() {
// only search if the value has changed // only search if the value has changed
if ( self.term != self.element.val() ) { if ( self.term != self.element.val() ) {
self.selectedItem = null;
self.search( null, event ); self.search( null, event );
} }
}, self.options.delay ); }, self.options.delay );