2

我将iCheck课程用于我的checkbox

<head>
...
<spring:url value="/resources/js/plugins/iCheck/all.css" var="iCheckCss" />
        <link rel="stylesheet" href="${iCheckCss}">
...
<spring:url value="/resources/js/plugins/iCheck/icheck.min.js" var="iCheckJs" />
        <script src="${iCheckJs}"></script>
...
</head>
<body>
...
<label><span id="select_all_${groupe_menu.gmnu_code}"></span> <input type="checkbox" class="minimal" id="selectToutC_${groupe_menu.gmnu_code}" /></label>
...
</body>
<script type="text/javascript">

    $(function() {

        $("span[id^='select_all_']").each(function(){
            $(this).html(_getText("admin.choix.select.deselect.tout"));
        });

        //iCheck for checkbox and radio inputs
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
            checkboxClass: 'icheckbox_minimal-blue',
            radioClass: 'iradio_minimal-blue'
        });

        $(":checkbox[id^='selectToutC_']").on("change", function(e) {
             alert("ddddd");
        });

    });

</script>

在运行时,当我单击复选框时,警报不会显示!那么有什么问题呢?

4

2 回答 2

5

这是 iCheck 的所有可用回调:Callbacks

您可以改用ifChanged事件

于 2016-11-11T07:53:05.883 回答
2

您可以将 ifChanged 事件用于 icheck

//copy address from correspondence address to permanent address
$('#same_address').on('ifChanged', function(event){
    if(this.checked) // if changed state is "CHECKED"
    {
        var correspondence_address = $('#correspondence_address').val();
        $('#permanent_address').val(correspondence_address);
    }
    else
    {
      $('#permanent_address').val('');
    }
});
于 2019-05-23T16:33:22.423 回答