Reputation: 2623
What am I missing here. I am trying to listen for the drop down event when the hamburger menu is clicked, and the menu is shown. I think it could be a markup problem, but can't see what I've done wrong.
<div id="head-nav">
<nav class="navbar navbar-default navbar-fixed-top head-nav">
<div class="container-fluid">
<div class="navbar-header head-nav__header">
<button type="button" class="navbar-toggle head-nav__hamburger" data-toggle="collapse"
data-target="#bsm-navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand head-nav__logo" href="#">
</a>
</div>
<div class="navbar-collapse collapse" id="bsm-navbar-collapse">
<!-- mobile -->
<ul class="nav navbar-nav hidden-sm hidden-md hidden-lg navbar-right">
<li><a href="/" class="head-nav__link">Home</a></li>
<li><a href="/home-loans/" class="head-nav__link">Compare Home Loans</a></li>
<li><a href="/special-offer/" class="head-nav__link">Special Offer</a></li>
<li><a href="/rate-chaser/" class="head-nav__link">Health Check</a></li>
<li><a href="/about-us/" class="head-nav__link">About Us</a></li>
</ul>
<!-- desktop -->
<ul class="nav navbar-nav navbar-right hidden-xs">
<li><a href="/home-loans/" class="head-nav__link head-nav__link--first">Compare Home Loans</a>
</li>
<li><a href="/special-offer/" class="head-nav__link">Special Offer</a></li>
<li><a href="#" class="head-nav__link">Big Bank Fight</a></li>
<li><a href="/rate-chaser/" class="head-nav__link">Health Check</a></li>
<li><a href="/home-loan-calculator/" class="head-nav__link head-nav__link--last">Calculators</a>
</li>
</ul>
</div>
</div>
</nav>
/* Latest compiled and minified JavaScript included as External Resource */
$(function() {
console.log('ready...');
$('*').on('shown.bs.dropdown', function () {
// never called up, although I have bound to everything....
console.log('called');
});
});
Upvotes: 1
Views: 1875
Reputation: 34
Try this::
$(function() {
$('#bsm-navbar-collapse').on('shown.bs.collapse', function () {
console.log('called');
});
});
Upvotes: 1
Reputation: 993
You are calling a 'collapse' element with your button, not a dropdown. try :
$('*').on('shown.bs.collapse', function () {
// never called up, although I have bound to everything....
console.log('called');
});
Upvotes: 0