Search code examples
javascriptjquerybootstrap-multiselect

Bootstrap-multiselect is checked after page reload


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>

Solution

  • Try do this like it is said in documentation .multiselect('refresh')

    I suppose you missed this:

    $(this).removeAttr('selected').prop('selected', false);