bootstrap multiselect - 如何在另一个span标签上显示所选值而不是buttonText

时间:2017-02-06 00:50:27

标签: javascript jquery bootstrap-multiselect

我想显示选定的值,例如(this screenshot is mixed)

不是buttonText(没有选中,全部选中,4选中......)

这是我的多选代码:

<script type="text/javascript">
    $(document).ready(function () {
        $('#product_reset_btn').on('click', function () {
            $('#product_choice_multi').multiselects('deselectAll',false);
        });
        $('#product_choice_multi').multiselects({
            //buttonContainer: '<div></div>',
            includeSelectAllOption: true,
            maxHeight: 200,
            enableClickableOptGroups: true,
            buttonClass: '',
            templates: {
                button: '<span class="multiselect dropdown-toggle" data-toggle="dropdown">product<img src="/~~~~?~?"></span>'
            },
            onChange: function (element, checked) {
                var brands = $('#product_choice_multi option:selected');
                var selected = [];
                $(brands).each(function (index, brand) {
                    selected.push([$(this).val()]);
                });
            }
        });
    });
</script>

0 个答案:

没有答案