Bootstrap ICheck 无法监听更改的事件
Bootstrap ICheck can not listen changed event
我有这个 jQuery 代码可以根据无线电是否已被检查来更新无线电。但是,这不会触发。
代码
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>
我也试过绑定点击功能和更改功能。但是change事件是听不到的。但是似乎都不起作用。当我不添加 Icheck.js 脚本时,一切正常。
有谁知道如何从引导程序 Icheckhelper 挂钩更改事件 class?
我发现有用的修复程序已从 github 论坛得到正确回答:read from this thread and How to handle radio event when iCheck-helper is used?
然后我更改了我的代码。问题已解决
$("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);
};
我有这个 jQuery 代码可以根据无线电是否已被检查来更新无线电。但是,这不会触发。
代码
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>
我也试过绑定点击功能和更改功能。但是change事件是听不到的。但是似乎都不起作用。当我不添加 Icheck.js 脚本时,一切正常。
有谁知道如何从引导程序 Icheckhelper 挂钩更改事件 class?
我发现有用的修复程序已从 github 论坛得到正确回答:read from this thread and How to handle radio event when iCheck-helper is used?
然后我更改了我的代码。问题已解决
$("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);
};