soundasleep / jquery-dropdown

Bootstrap-style dropdowns with some added features and no dependencies.
Other
767 stars 268 forks source link

Dropdown menu on button does not close #44

Closed ekiruluta closed 10 years ago

ekiruluta commented 10 years ago

I implemented the dropdown as a button. When I click the button the menu displays correctly but when I select a menu item the dropdown does not go away. What am I missing?

Here is the example code:

Setting up drop down menu...

<div id="dropdown-1" class="dropdown dropdown-tip">
    <ul class="dropdown-menu">
    <li onclick="show1()"><a href="#">Find Set 1...</a></li>
    <li class="dropdown-divider"></li>
    <li><a href="show2()">Find Set 2...</a></li>
    <li><a href="show3()">Find Set 3...</a></li>
    <li class="dropdown-divider"></li>
    <li><a href="show4()">Find Set 4...</a></li>
    <li><a href="show5()">Find Set 5...</a></li>
    </ul>
</div>

Activating drop down menu using a button...

<button name=\"menuOps\" data-dropdown=\"#dropdown-1\" />Menu Options</button>
claviska commented 10 years ago

Try handling the event in the anchor instead of the list element.

On Aug 24, 2013, at 1:33 AM, ekiruluta notifications@github.com wrote:

I implemented the dropdown as a button. When I click the button the menu displays correctly but when I select a menu item the dropdown does not go away. What am I missing?

Here is the example code:

Setting up drop down menu...

Activating drop down menu using a button...

<button name=\"menuOps\" data-dropdown=\"#dropdown-1\" />Menu Options — Reply to this email directly or view it on GitHub.

ekiruluta commented 10 years ago

The solution I found was to call the hide (hide the dropdown) method in my Javascript handlers.