Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3 dropdown events not firing

I am trying to get an shown event fired at dropdown at this site running on BS3.0

http://hmelius.com/avant/index.php

I have tried this code in the console (from the BS3 documentation page) but with no luck

$('.dropdown-toggle').on('shown.bs.dropdown', function () {
  console.log("shown");
});
like image 474
elvista Avatar asked Nov 12 '13 17:11

elvista


2 Answers

I believe the events fire on the "parent" not the toggle, so it would be the element above the toggle with .dropdown or .btn-group; the dropdown wrapping element

take a look at the source to see what I mean: https://github.com/twbs/bootstrap/blob/master/js/dropdown.js

like image 53
monastic-panic Avatar answered Nov 03 '22 16:11

monastic-panic


Based on @monastic-panic 's comment this works

$(".dropdown-toggle").parent().on('show.bs.dropdown', function () {
  console.log("shown");
});
like image 26
Justin Leveck Avatar answered Nov 03 '22 17:11

Justin Leveck