Fixed problem on combobox with search limit.

The IPA.combobox_widget has been modified such that if the drop-down
list doesn't contain the stored value (due to search limit) it will
not select anything from the list.

The widget has also been modified not to select the value that matches
the filter automatically because that might not be the user's intention.

Ticket #1819
This commit is contained in:
Endi S. Dewata 2011-09-20 15:12:05 -05:00
parent c6f5806ed8
commit e254ea5d30

View File

@ -1670,12 +1670,7 @@ IPA.combobox_widget = function(spec) {
keypress: function(e) { keypress: function(e) {
if (e.which == 13) { // Enter if (e.which == 13) { // Enter
var filter = that.filter.val(); var filter = that.filter.val();
that.search( that.search(filter);
filter,
function(data, text_status, xhr) {
that.select(filter);
}
);
} }
} }
}).appendTo(div); }).appendTo(div);
@ -1685,12 +1680,7 @@ IPA.combobox_widget = function(spec) {
icon: 'search-icon', icon: 'search-icon',
click: function() { click: function() {
var filter = that.filter.val(); var filter = that.filter.val();
that.search( that.search(filter);
filter,
function(data, text_status, xhr) {
that.select(filter);
}
);
return false; return false;
} }
}).appendTo(div); }).appendTo(div);
@ -1783,11 +1773,16 @@ IPA.combobox_widget = function(spec) {
var option; var option;
if (value) { if (value) {
// select specified value
option = $('option[value="'+value+'"]', that.list); option = $('option[value="'+value+'"]', that.list);
} else { } else {
// select first available option
option = $('option', that.list).first(); option = $('option', that.list).first();
} }
// if no option found, skip
if (!option.length) return;
option.attr('selected', 'selected'); option.attr('selected', 'selected');
that.set_value(option.val()); that.set_value(option.val());