skip to Main Content

my question is simple but documentation or google is sparse about that…

I have a notification dropdown that I want to reload by ajax each time that exact dropdown is closed.

I just need to know which element do I need to listen to : the .dropdown ? .dropdown-toggle ? Or .dropdown-menu ?

Here is my code sample with IDs to be more specific :

<li class="dropdown" id='notif_drp'>
    <a id="notif_toggle" href="#" data-toggle="dropdown" class="dropdown-toggle">Open</a>
    <ul id='notif_ul' class="dropdown-menu">
        <li>Notification 1</li>
    </ul>
</li>

2

Answers


  1. You can bind bootstrap’s event, which is shown here.
    There are 4 event you can use.

    And I made an example. http://jsbin.com/gudevoxara/edit?html,console,output

    Login or Signup to reply.
  2. From twitter bootstrap docs

    All dropdown events are fired at the .dropdown-menu’s parent element.

    So for your example the li tag with class dropdown and id notif_drp
    You can see it at codepen

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search