Bootstraps ICheck ne peut pas écouter l'événement modifié

Dec 15 2020

J'ai ce code Jquery pour mettre à jour la base des radios sur si une radio a été vérifiée. Cependant, cela ne se déclenche pas.

Code

    this.init = function() {
    $.ajax({ "url": "/cms/api/task_management/init", "contentType": "application/json", "dataType": "json", "type": "POST" }).done(function(map) { if ($("#title").val() || $("#problemCls").val() || $("#targetFunc").val() || $("#status").val() || $("#priority").val()) {
            search();
        } else {
            callBackInit(map);
        }
    }).fail(failCallback);
    $("input[type='radio']").on("ifChanged", function (event) { if ($("#display-method-unique").prop("checked")) {
            renderDataTable(self.taskManagementList);
        } else {
            renderDataTable(self.allDataList);
        }
    }).iCheck({
        radioClass: 'iradio_flat-green'
    });

HTML

<div class="row">
     <div class="col-md-4 col-sm-12 col-xs-12">
          <div class="radio">
               <input type="radio" name="display-method" id="display-method-unique" class="flat"><label for="display-method-unique">Doing</label>
               <input type="radio" name="display-method" id="display-method-all" class="flat"><label for="display-method-all">End</label>
           </div>
    </div>
</div>

J'ai également essayé de lier la fonction de clic et la fonction de changement. Mais l'événement de changement ne peut pas être écouté. Cependant, ni l'un ni l'autre ne semblent fonctionner. Tout fonctionne bien lorsque je n'ajoute pas le script Icheck.js.

Est-ce que quelqu'un sait comment se connecter à un événement modifié à partir de la classe Icheckhelper bootstraps?

Réponses

1 XinLiu Dec 16 2020 at 07:18

J'ai trouvé un correctif utile comme cela a été correctement répondu sur le forum github: lire à partir de ce fil et Comment gérer l'événement radio lorsque iCheck-helper est utilisé?

Puis j'ai changé mon code. Le problème est résolu.

$("input[name='display-method']").iCheck({radioClass: 'iradio_flat-green'}); this.init = function() { $.ajax({
        "url": "/cms/api/task_management/init",
        "contentType": "application/json",
        "dataType": "json",
        "type": "POST"
    }).done(function(map) {
        if ($("#title").val() || $("#problemCls").val() || $("#targetFunc").val() || $("#status").val() || $("#priority").val()) { search(); } else { callBackInit(map); } $("input[name='display-method']").on("ifCreated ifClicked ifChanged ifChecked ifUnchecked ifDisabled ifEnabled ifDestroyed check", function (event) {
            if ($("#display-method-unique").prop("checked")) {
                renderDataTable(self.taskManagementList);
            } else {
                renderDataTable(self.allDataList);
            }
        });
    }).fail(failCallback);
};