bootstrap-multiselect 显示全部选择的值 默认不选择第一项 动态重建

在bootstrap-multiselect 选择的时候,选择为4个的时候 会显示 4 selectd,选择全部的时候 会显示 all  selectd。

现在的要求是全部显示出来。

    通过调试工具发现 title 和 text 内容是有区别的,title的值是我们需要的。

    在 bootstrap-multiselect.js 中搜索   multiselect-selected-text(class)

     发现在 updateButtonText: function() {} 方法 中 有设置title和text 内容,将 设置text的内容 修改为设置title的值。

原代码:

updateButtonText: function() {
            var options = this.getSelected();

            // First update the displayed button text.
            if (this.options.enableHTML) {
                $('.multiselect .multiselect-selected-text', this.$container).html(this.options.buttonText(options, this.$select));
            }
            else {
                $('.multiselect .multiselect-selected-text', this.$container).text(this.options.buttonText(options, this.$select));
            }

            // Now update the title attribute of the button.
            $('.multiselect', this.$container).attr('title', this.options.buttonTitle(options, this.$select));

        },

修改为


    updateButtonText: function() {
            var options = this.getSelected();

            // First update the displayed button text.
            if (this.options.enableHTML) {
                $('.multiselect .multiselect-selected-text', this.$container).html(this.options.buttonTitle(options, this.$select));
            }
            else {
                $('.multiselect .multiselect-selected-text', this.$container).text(this.options.buttonTitle(options, this.$select));
            }

            // Now update the title attribute of the button.
            $('.multiselect', this.$container).attr('title', this.options.buttonTitle(options, this.$select));
            
        },


还有默认选择第一项的问题

设置
       var x = document.getElementById("xxxxx");    
          x.selectedIndex = -1;

$(".multiselect-selected-text").html("请选择");


动态重建:

var html = html+="<option value='"+obj.id+"'>"+obj.pro_Name+"</option>";

$("#xx").html(html);

 $('#xx').multiselect('rebuild');


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值