soundasleep / jquery-dropdown

Bootstrap-style dropdowns with some added features and no dependencies.
Other
767 stars 268 forks source link

display dropdown using different data attribute #75

Closed alokpant closed 9 years ago

alokpant commented 9 years ago

I am trying to dynamically load the contents in the dropdown. But using data-dropdown, the dropdown is showed before the content is loaded. I thought alternative way is to use a different data attribute and call the dropdown programatically.

<a class="dataTrigger" href="#" data-menu="#dropdown1">Menu</a>

<div id="dropdown1">
//contents here
</div>

$('.dataTrigger').on('click', function () {
 var dtval = $(this).attr('data-menu');
 $(dtval).dropdown('show');
});

But it does not load the dropdown. Is this possible?

Thank you.

claviska commented 9 years ago

You could modify the menu's HTML directly, otherwise you'd need to add a beforeShow event.