繁体   English   中英

Kendo复选框检查事件

[英]Kendo Checkbox check event

我正在尝试捕获kendo复选框事件,但无法正常工作。 我确定我缺少什么。 当我在这个简单的事情上花了一个多小时时,我很累。 以下是代码段。

HTML

<div class="bottomPadding row">
    <div class="col-md-4 col-sm-4 col-xs-12 col">
        <label>Send Activation Link</label>
    </div>
    <div class="col-md-6 col-sm-6 col-xs-12 col">
        <input id="sendLink" type="checkbox" data-bind="checked: Account.IsLink" />
    </div>
</div>

还有JS代码

$("#sendLink").click(function () {
    if (this.checked) {
        console.log("hit");
    }
});

请纠正我弄乱的地方。

PS:我提到的SO答案很少,有些没有答案,有些答案在我的情况下不起作用。

我已经在计算机上运行了您的代码,并且收到点击事件的罚款,这是我的代码:

    <div class="row">
    <div class="col-md-4 col-sm-4 col-xs-12 col">
        <label>Send Activation Link</label>
    </div>
    <div class="col-md-6 col-sm-6 col-xs-12 col">
        <input id="sendLink" type="checkbox" data-bind="checked: Account.IsLink" />
    </div>
</div>
<script>
    $(document).ready(function () {
        clickHookup();
    })
</script>

在我的JS文件中:

function clickHookup() {
    $("#sendLink").click(function () {
      if (this.checked) {
        console.log("hit");
      }
    });
}

上面的代码工作正常,但不是kendo。 它是纯jQuery。 要使用剑道,请检查此

 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <script src="https://code.jquery.com/jquery-3.1.0.js"></script> <link href="https://da7xgjtj801h2.cloudfront.net/2015.2.624/styles/kendo.common.min.css" rel="stylesheet" type="text/css" /> <link href="https://da7xgjtj801h2.cloudfront.net/2015.2.624/styles/kendo.silver.min.css" rel="stylesheet" type="text/css" /> <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <script src="https://da7xgjtj801h2.cloudfront.net/2015.2.624/js/kendo.ui.core.min.js"></script> <title>JS Bin</title> </head> <body> <div class="bottomPadding row"> <div class="col-md-4 col-sm-4 col-xs-12 col"> <label>Send Activation Link</label> </div> <div class="col-md-6 col-sm-6 col-xs-12 col"> <input id="sendLink" type="checkbox" data-bind="checked: Account.IsLink" /> </div> <div class="col-md-4 col-sm-4 col-xs-12 col"> <label>Copy Activation Link</label> </div> <div class="col-md-6 col-sm-6 col-xs-12 col"> <input id="sendLinkCopy" type="checkbox" data-bind="checked: Account.IsLink" /> </div> </div> <script> $("#sendLink").click(function () { if (this.checked) { console.log("hit"); } }); var viewModel = kendo.observable({ Account: { IsLink: false } }); kendo.bind($("#sendLink"), viewModel); kendo.bind($("#sendLinkCopy"), viewModel); </script> </body> </html> 

请注意,sendLinkCopy基于sendLink复选框中的更改进行更新。 它由剑道处理。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM