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

Is it possible to show drop down on focus/click?

Open JoeFirebaugh opened this issue 11 years ago • 3 comments
trafficstars

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

JoeFirebaugh avatar Jul 24 '14 21:07 JoeFirebaugh

Hi. I have the exact question. Has anyone found any solution for this? It would be very much appreciated.

alirezanoori1986 avatar Sep 03 '14 09:09 alirezanoori1986

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.

ronan-mch avatar Sep 06 '14 13:09 ronan-mch

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().

amkoehler avatar Apr 10 '15 16:04 amkoehler