【发布时间】:2020-12-16 01:22:00
【问题描述】:
我有这个 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>
我也尝试过绑定到 click 函数和 change 函数。但是无法监听更改事件。然而,两者似乎都不起作用。当我不添加 Icheck.js 脚本时,一切正常。
有人知道如何从引导程序 Icheckhelper 类中挂钩更改的事件吗?
【问题讨论】:
-
你能把代码放在像这样的 jsfiddle 中吗? jsfiddle.net/aljon254/LuuLrm6d 还是这个? jsfiddle.net/bantikyan/jcfekw2j/2 还是这个? jsfiddle.net/amindunited/47nq6at7
-
之前有人问过类似的问题,看看这里对你有帮助吗? stackoverflow.com/questions/20832568/… 单选按钮上没有单击事件,因此您必须检测第一个单选是否已更改为:jsfiddle.net/hmartiro/g4YqD/1
-
@NathanielFlick 谢谢你的回答。我用了iCheck.js之后就不行了。
-
使用 iCheck 中的 ifChanged 事件; stackoverflow.com/questions/25562062/…
-
@NathanielFlick 非常感谢!有用,问题解决了。
标签: javascript jquery twitter-bootstrap icheck