I am implementing Twitter Bootstrap and attempting to launch a modal popup by clicking on a menu item. Below is the code snippet:
<div class="navbar navbar-fixed-bottom">
<div class="navbar-inner">
<ul class="nav pull-right">
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Menu</a>
<ul class="dropdown-menu">
<li class="active"><a href="">Some item 1</a></li>
<li class=""><a href="">Some item 2</a></li>
</ul>
</li>
<li class="dropdown"><a href="#myModal" class="dropdown-toggle" data-toggle="modal">
Contacts</a></li>
</ul>
</div>
<!-- /.navbar-inner -->
</div>
My Modal window code:
<div class="modal hide" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×</button>
<h3 id="myModalLabel">
Modal header</h3>
</div>
<div class="modal-body">
<p>
One fine body…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">
Close</button>
<button class="btn btn-primary">
Save changes</button>
</div>
</div>
Upon clicking the first menu item with dropdown data-toggle, it changes color. However, when I click on the second menu item (Contacts) with modal data-toggle, the color does not change. I have added an onclick event for the "Contacts" li element:
onclick="$(this).addClass('modal-open-li');"
I have created my own modal-open-li
class to handle the click effect. How can I revert the color of the li
element when closing the modal popup? Also, is it possible to add multiple data-toggles for the same li
element like data-toggle="modal dropdown"
?