I'm using Bootstrap-multiselect plugin and can't get my head around how to reset all option to be deselected after I reload the page. When I just hit reload in my FF - page reload but the selected option stays.
I've tried following
<script type="text/javascript">
$(document).on('ready', function() {
function getgraph(checked, element) {
var data ={blablabla}
$("#get_graph").load("get_graph", data);
}
function selector_onchange(element, checked) {
getgraph(checked, element.val());
};
$('#multiselect').multiselect({
enableHTML: true,
onChange: selector_onchange
});
$('#multiselect').multiselect('deselectAll', true);
$('#multiselect').multiselect('refresh');
getgraph(null, null);
});
</script>
on page load do something like:
$('#multiselect').multiselect('deselectAll', false);
see docs http://davidstutz.github.io/bootstrap-multiselect/#methods .multiselect('deselectAll', justVisible)
Hope that helps
Try do this like it is said in documentation .multiselect('refresh')
I suppose you missed this:
$(this).removeAttr('selected').prop('selected', false);
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.