I am trying to trigger an event after a buton group is closed (to catch mutiple changes inside that button group).
<div class="btn-group">
<span id="experiment-filter-group" class="btn-group pull-right open">
<button type="button" style="width:auto" class="dropdown-toggle btn btn-small" data-toggle="dropdown">Click Here <b class="caret"></b></button>
<ul class="dropdown-menu" style="max-height: 400px; overflow-y: auto; overflow-x: hidden;">
<li class="active"><a href="javascript:void(0);" style="padding:0;"><label style="margin:0;padding:3px 20px 3px 20px;width:100%;height:100%;cursor:pointer;"><input style="margin-bottom:5px;" type="checkbox" value="0"> X Option</label></a></li>
<li><a href="javascript:void(0);" style="padding:0;"><label style="margin:0;padding:3px 20px 3px 20px;width:100%;height:100%;cursor:pointer;"><input style="margin-bottom:5px;" type="checkbox" value="1"> Y Option </label></a></li>
</ul>
</span>
</div>
<script>
$('.btn-group').on("closed", function(e){
console.log("closed");
});
</script>
this is not working..
There is no twitter bootstrap dropdown on close event, but you can do something like this:
$(document).ready(function () {
$('#btn-group').data('open', false);
$('#dropdown-button').click(function () {
if ($('#btn-group').data('open')) {
$('#btn-group').data('open', false);
onCloseEvent();
} else $('#btn-group').data('open', true);
});
$(document).click(function () {
if ($('#btn-group').data('open')) {
$('#btn-group').data('open', false);
onCloseEvent();
}
});
function onCloseEvent() {
alert("close");
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.