【问题标题】:How to make bootstrap multi-select plugin working with icheck plugin如何使引导多选插件与 icheck 插件一起使用
【发布时间】:2014-09-29 19:08:19
【问题描述】:

我在我的网页上使用了这个bootstrap multiselect 和这个checkbox/radio plugin。突然,我注意到当 icheck 放入多选时,没有默认和自定义的多选功能!这是我没有 icheck 插件的工作:Fiddle 这是带有 icheck 的Fiddle,其中多选功能不起作用。我也需要使用 icheck 的功能:

$('#data-type').multiselect({
    includeSelectAllOption: true,
    buttonWidth: '90%',
    nonSelectedText: 'Select multiple option',
    onChange: function(element, checked) {
        var selectedOptions = $('#data-type option:selected');

        if (selectedOptions.length == 0) {
           // Custom code
           alert('All are unchecked!');
        }
    }

});

$('input').iCheck({
    checkboxClass: 'checkbox-default',
    radioClass: 'radio-default',
});

如何使用 icheck 插件再次使多选工作?

【问题讨论】:

    标签: jquery icheck bootstrap-multiselect


    【解决方案1】:

    这是 iCheck https://github.com/fronteed/iCheck/issues/68 中的一个错误。该错误已在版本 2 中修复。 iCheck 也被替换为 icheck。这是你的榜样http://jsfiddle.net/koa58o4o/1/

    $('input').icheck({
        checkboxClass: 'checkbox-default',
        radioClass: 'radio-default',
    });
    

    使用“全选”http://jsfiddle.net/koa58o4o/4/

    【讨论】:

    • 好吧,“全选”似乎无法正常工作。如何让它与 icheck 一起工作?
    • @user1896653,我已经用“全选”示例更新了我的答案。
    • 非常感谢您的帮助。顺便说一句,您已经添加了一些额外的代码以使其正常工作。这意味着,icheck 仍然会替换默认的表单功能吗?还是icheck的bug吗?
    • 不,这不是错误。按照设计,您需要手动更新复选框状态以进行更改,这些更改是在插件外部完成的。 (github.com/fronteed/iCheck/tree/2.x-beta$('input').icheck('update');)
    • 知道了,再次感谢!
    猜你喜欢
    • 1970-01-01
    • 2018-01-28
    • 1970-01-01
    • 1970-01-01
    • 2014-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多