bootstrap-combobox
bootstrap-combobox copied to clipboard
Proposed: lookupOnly option to allow input text to persist
We're using bootstrap-combobox inside jqGrid with great success. However, on one of the pages, we need a combobox that will search a given list of items and if not found, allow the (unfound) new entry to be accepted and added to the list.
In the current bootstrap-combobox, it seems that its intended as a lookup tool only. I've made the following modifications to the blur method to allow the input text to persist:
, blur: function (e) {
var that = this;
this.focused = false;
var val = this.$element.val();
if (!this.selected && val !== '' ) {
// by default, bootstrap-combobox wants to blank out the input box
// if you haven't selected anything from inside the list
if( this.options.lookupOnly ) {
val = ''; // blank out the input box, as nothing was found
this.$element.val('');
}
this.$source.val(val).trigger('change');
this.$target.val(val).trigger('change');
}
if (!this.mousedover && this.shown) {setTimeout(function () { that.hide(); }, 200);}
}
I would propose adding the lookupOnly option (true to behave as it currently does, false to allow the input text to persist).
Note that the code above does not add to the existing list--we have external code currently handling this, although it would be nice if the control handled this functionality as well, tied to the lookupOnly option.
+1
Looking for feature that, if entry not found in list of items, allow the new entry to be accepted and added to the list
+1
+1