【问题标题】:Bootstrap Enable/Disable Chosen Select DynamicallyBootstrap 启用/禁用动态选择
【发布时间】:2013-05-21 20:44:30
【问题描述】:

有谁知道我如何动态启用/禁用 Bootstrap Chosen 选择框? 我创建了一个带有两个选择框的 JSFiddle。 第一个只是切换所选选择的启用/禁用。

$(document).on('change','#option', function(){
   // not sure what to do here
});

http://jsfiddle.net/yakitori/H38fU/3/

【问题讨论】:

    标签: jquery twitter-bootstrap jquery-chosen


    【解决方案1】:

    将你的jQuery更改为以下

    $(document).ready(function(){
    
        $(document).on('change','#option',function(){
            if($(this).val() == 1){
                // enable select box
                $("#chzn-select").attr('disabled', false).trigger("liszt:updated");
            }else{
                // disable select box
                $("#chzn-select").attr('disabled', true).trigger("liszt:updated");
            }
            $("#option").trigger("chzn:updated");
        });
    
    });
    

    【讨论】:

      【解决方案2】:

      只需使用 $('.selectpicker').selectpicker('refresh');执行您的代码后... :)

      【讨论】:

        猜你喜欢
        • 2016-07-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-07-22
        • 2017-09-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多