drgullin / icheck

Highly customizable checkboxes and radio buttons (jQuery & Zepto)
http://fronteed.com/iCheck
7.38k stars 1.62k forks source link

Kendo UI custom binding for Checkbox #230

Open danparker276 opened 9 years ago

danparker276 commented 9 years ago

This is what I used to create a custom binding for Kendo UI, seems to work pretty good

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

You should use v2 version, it's much better.

danparker276 commented 9 years ago

but v2 is still rc right. I'd still have to do the following for binding thought right?

drgullin commented 9 years ago

V2 still RC, but it works quite well. It's much better than v1 in performance. Note that v2 has a bit different methods names.