【问题标题】:Kendo MVVM custom binding for a click in checkbox用于单击复选框的 Kendo MVVM 自定义绑定
【发布时间】:2015-01-31 11:53:13
【问题描述】:

所以,我想为我的复选框使用 iCheck,但这需要自定义绑定。 Kendo MVVM、knockout 或任何其他 js 库。

我的自定义绑定几乎完美无缺,但它不会在单击复选框时触发。如果我将输入从复选框更改为文本输入,则单击自定义绑定效果很好。

kendo.data.binders.myICheck = kendo.data.Binder.extend({
    init: function (element, bindings, options) {
        //call the base constructor
        kendo.data.Binder.fn.init.call(this, element, bindings, options);
        var that = this;
        //listen for the change event of the element
        $(that.element).on("click", function () {
            that.click(); //call the change function
        });
    },
    click: function () {
        this.bindings["myICheck"].set(false);
    },
    refresh: function () {
        var value = this.bindings["myICheck"].get();
        if (value) {
            $(this.element).iCheck('check');
        } else {
            $(this.element).iCheck('uncheck');
        }
    }
});

HTML 是

input indeterminate="false" data-bind="myICheck: rememberUserInfo" class="check">

【问题讨论】:

    标签: jquery mvvm kendo-ui


    【解决方案1】:

    啊,想通了,iClick 有它自己的事件: 我需要使用 ifChagned 或 ifClicked

     $(that.element).on("ifClicked", function () {
    

    http://fronteed.com/iCheck/

    【讨论】:

      猜你喜欢
      • 2013-02-12
      • 2013-06-03
      • 2013-01-10
      • 2013-10-15
      • 2010-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多