jabestrada free asked 8 years ago


I'm using the dropdown markup from the sample:
<div class="dropdown">
  <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Dropdown Example
  <span class="caret"></span></button>
  <ul class="dropdown-menu">
    <li><a href="#">HTML</a></li>
    <li><a href="#">CSS</a></li>
    <li><a href="#">JavaScript</a></li>
  </ul>
</div>
My objective is to capture the click of the menu items and prevent the default anchor tag behavior from happening. My code so far:
 $(function () {
                $(".dropdown-menu > li  a").click(function () {
                    console.log("clicked");
                    return false;
                });
            });
All's fine except the dropdown menu is not dismissed. What code would dismiss/close the dropdown menu? Thanks.

jabestrada free answered 8 years ago


Thanks, Michal

Michal Szymanski staff answered 8 years ago


Take a look at the bootstrap dropdowns documentation . I would try to use event hide.bs.dropdown as a callback function

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags