简体   繁体   中英

Keep dropdown menu open Bootstrap 2.3.2 on Rails 4.0

I am using dropdown on Bootstrap 2.3.2 on Rails 4.0 and I am trying to keep the dropdown menu open even after clicking a button from the dropdown menu (so I only want it to close when I re-click the dropdown-toggle element)

I tried to follow the solution here https://stackoverflow.com/questions/14544741/angularjs-directive-to-stoppropagation# = to no avail...Below is what I tried to do on my html.erb to make it work. Please tell me what I am doing wrong or if you have a better working solution, let me know. Any hint would be much appreciated, thanks in advance!

<div class="dropdown">
  <a **ng-click="$event.stopPropagation();"** class="dropdown-toggle" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href="/page.html">
    Dropdown
    <b class="caret"></b>
  </a>
  <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
    <div>
      <button type="button" class="btn btn-primary" data-toggle="button">
    </di>
  </ul>
</div>

Shouldn't be the stop propagation applied to the clickable element itself ?

<div class="dropdown">
  <a class="dropdown-toggle" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href="/page.html">
    Dropdown
    <b class="caret"></b>
  </a>
  <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
    <div ng-click="$event.stopPropagation();">
      <button type="button" class="btn btn-primary" data-toggle="button">
    </di>
  </ul>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM