1

I can't seem to open this dropdown menu on page load. Can anyone help? Documentation on Bootrap 3 is here: http://getbootstrap.com/javascript/#dropdowns

I tried this but it doesn't seem to work

$('#myDropdown').dropdown()

Ultimately, I need to be able to open a drop down that is inside a collapsible menu. For example, I want to open the first down down menu after the user clicks on the menu button. but I can't get it to work.

http://jsfiddle.net/G4k4F/3

Edit: When the navbar is shown, use a timer to wait 1 millisecond before calling .dropdown('toggle'). Like this.

function OpenDropDown() {
    $('.dropdown-menu').dropdown('toggle');
};

$('.collapse.navbar-collapse').on('show.bs.collapse', function () {
    window.setTimeout(OpenDropDown, 1);
});
duyn9uyen
  • 9,585
  • 12
  • 43
  • 54

2 Answers2

5

try this :

$(function () {
  $('.dropdown-menu').dropdown('toggle');
});
Jérôme Teisseire
  • 1,518
  • 1
  • 16
  • 26
  • Why doesn't that work when trying to open a drop down that is inside of a collapsible container? http://jsfiddle.net/G4k4F/3/ – duyn9uyen Feb 04 '14 at 21:39
0

Try this..

$(function () {
    $('[data-toggle="dropdown"]').dropdown('toggle');
});

Or you can use the button id like:

 $('#dLabel').dropdown('toggle');
Carol Skelly
  • 351,302
  • 90
  • 710
  • 624