From 67386163989aca3952a9a8a92a57cc7f630a0ec8 Mon Sep 17 00:00:00 2001 From: Tal Einat Date: Sun, 12 May 2013 15:11:57 +0300 Subject: [PATCH 1/2] added 'force_match' option When set to false, disables clearing the text box when the text doesn't match an option. Default is true, which retains the previous behavior. --- js/bootstrap-combobox.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/bootstrap-combobox.js b/js/bootstrap-combobox.js index dc908bf..68ad581 100755 --- a/js/bootstrap-combobox.js +++ b/js/bootstrap-combobox.js @@ -200,7 +200,7 @@ var that = this this.focused = false var val = this.$element.val() - if (!this.selected && val !== '' ) { + if (!!this.options.force_match && !this.selected && val !== '' ) { this.$element.val('') this.$source.val('').trigger('change') this.$target.val('').trigger('change') @@ -231,6 +231,7 @@ template: '
' , menu: '' , item: '
  • ' + , force_match: true } $.fn.combobox.Constructor = Combobox From 911473f2ec0e72a927092adb2f8ada6c58179ae8 Mon Sep 17 00:00:00 2001 From: Tal Einat Date: Thu, 16 May 2013 19:03:36 +0300 Subject: [PATCH 2/2] when losing focus and force_match is false, set the value of this.$target --- js/bootstrap-combobox.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js/bootstrap-combobox.js b/js/bootstrap-combobox.js index 68ad581..8654726 100755 --- a/js/bootstrap-combobox.js +++ b/js/bootstrap-combobox.js @@ -200,10 +200,14 @@ var that = this this.focused = false var val = this.$element.val() - if (!!this.options.force_match && !this.selected && val !== '' ) { - this.$element.val('') - this.$source.val('').trigger('change') - this.$target.val('').trigger('change') + if (!!this.options.force_match) { + if ( !this.selected && val !== '' ) { + this.$element.val('') + this.$source.val('').trigger('change') + this.$target.val('').trigger('change') + } + } else { + this.$target.val(val).trigger('change') } if (!this.mousedover && this.shown) setTimeout(function () { that.hide() }, 200) }