bootstrap-combobox
bootstrap-combobox copied to clipboard
Is it possible to show drop down on focus/click?
Is there a config setting or neat hack to make this show the drop-down immediately when the text area is clicked or brought into focus?
Thanks, Joseph Firebaugh
Hi. I have the exact question. Has anyone found any solution for this? It would be very much appreciated.
Perhaps you could use the click event on the text box to simulate a click event on the button? I was able to do something like this on the test app using the following code:
$($('[data-dropdown="dropdown"]')[1]).click()
In my local app I wrote this:
$('.combobox').click(function(){
$(this).siblings('.dropdown-toggle').click();
});
I'm using the siblings filter here because I want to have multiple comboboxes, so I only want to trigger the click on the nearest one.
I know this issue is a few months old, but I found another, possibly more complete solution. Adding this.lookup to focus: of bootstrap-combobox.js does the trick for me.
focus: function (e) {
if (!this.selected && this.$element.val() == '' ) {
this.lookup();
}
this.focused = true;
}
Focus gets called again if you select an element in the list, so I added the if statement to make sure nothing is selected before calling lookup().