bootstrap-combobox icon indicating copy to clipboard operation
bootstrap-combobox copied to clipboard

Proposed: lookupOnly option to allow input text to persist

Open kopmanis opened this issue 9 years ago • 4 comments
trafficstars

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.

kopmanis avatar Oct 04 '16 19:10 kopmanis

+1

jankod avatar Oct 07 '16 09:10 jankod

Looking for feature that, if entry not found in list of items, allow the new entry to be accepted and added to the list

chsreedhar avatar Oct 27 '16 19:10 chsreedhar

+1

jonathan-scholbach avatar Dec 19 '16 12:12 jonathan-scholbach

+1

TookIsTaken avatar Dec 22 '16 18:12 TookIsTaken