I'm using David Sutz's bootstrap multiselect and I can't find a way to modify the .dropdown-menu
on onDropdownShow
. Setting the width in the function below does not work:
$('#flavor').multiselect({
onDropdownShow: function(event) {
$(this).closest('.dropdown-menu').css('width','500px')
}
});
The problem lays in the $(this)
which does not seem to be a DOM node, although I expect it to #flavor
.
What I'm trying to do is dynamically change the menu's width depending on the window's width (basically making it responsive), so the code needs to be executed every time the menu is being opened. Additionally I have multiple multiselect boxes on my page, so it really needs to be a generic function without hard coded DOM references, hence the need for $(this)
to work.