davidstutz / bootstrap-multiselect

JQuery multiselect plugin based on Twitter Bootstrap.
https://davidstutz.github.io/bootstrap-multiselect/
Other
3.66k stars 1.99k forks source link

"Simulate single selections using checkboxes" Example not working in docs #1247

Open LucasRoquilly opened 1 year ago

LucasRoquilly commented 1 year ago

Hello,

Thanks to all those contributing.

It seems to me an example in the docs is not working. It is the "Simulate single selections using checkboxes" example.

I changed this code (which is in the docs)

<script type="text/javascript">
    $(document).ready(function() {
        $('#example-simulate-single').multiselect({
            on: {
                change: function(option, checked) {
                    var values = [];
                    $('#example-simulate-single option').each(function() {
                        if ($(this).val() !== option.val()) {
                            values.push($(this).val());
                        }
                    });
                    $('#example-simulate-single').multiselect('deselect', values);
                }
            }
        });
    });
</script>

to this code below to make it work

<script type="text/javascript">
    $(document).ready(function() {
        $('#example-simulate-single').multiselect({
                onChange: function(option, checked) {
                    var values = [];
                    $('#example-simulate-single option').each(function() {
                        if ($(this).val() !== option.val()) {
                            values.push($(this).val());
                        }
                    });
                    $('#example-simulate-single').multiselect('deselect', values);
                }
        });
    });
</script>

I suggest updating the docs if this is confirmed