Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it a real combo box #280

Open
tflori opened this issue Feb 1, 2023 · 0 comments
Open

Make it a real combo box #280

tflori opened this issue Feb 1, 2023 · 0 comments

Comments

@tflori
Copy link

tflori commented Feb 1, 2023

Only now I found out that this jquery extension is not a real combo box but a non-editable combo box. Maybe it is just me but a combo box for me means that you can decide to enter something new: https://en.wikipedia.org/wiki/Combo_box

First I thought clearIfNoMatch: false would make it that way. At least it looks like it. But the $target value does never get updated with the entered text and gets set to empty string even when clearIfNoMatch is false.

My proposal is to update the $target value with every keup event and don't clear it as well. Here is a diff how I use it:

Index: bootstrap-combobox.js
===================================================================
diff --git a/bootstrap-combobox.js b/bootstrap-combobox.js
--- a/bootstrap-combobox.js
+++ b/bootstrap-combobox.js
@@ -403,6 +403,9 @@
                 default:
                     this.clearTarget();
                     this.lookup();
+                    if (!this.selected && !this.clearIfNoMatch) {
+                        this.$target.val(this.$element.val());
+                    }
             }
 
             e.stopPropagation();
@@ -418,10 +421,11 @@
             this.focused = false;
             var val = this.$element.val();
             if (!this.selected && val !== '' ) {
-                if(that.clearIfNoMatch)
+                if (this.clearIfNoMatch) {
                     this.$element.val('');
-                this.$source.val('').trigger('change');
-                this.$target.val('').trigger('change');
+                    this.$target.val('').trigger('change');
+                }
+                this.$source.val('').trigger('change');
             }
             if (!this.mousedover && this.shown) {setTimeout(function () { that.hide(); }, 200);}
         }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant