This is a migrated thread and some comments may be shown as answers.

<button> Disabled from boolean in observable

3 Answers 192 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 18 May 2012, 06:59 PM
How do I set enable/disable based on a value in the observable?

I tried everything I can think of.

Thanks!

3 Answers, 1 is accepted

Sort by
0
Marc
Top achievements
Rank 1
answered on 30 May 2012, 10:45 AM
Hi James,

there is an example in the MVVM documentation, see http://www.kendoui.com/documentation/framework/mvvm/bindings/disabled.aspx 

hth
0
Wannes
Top achievements
Rank 1
answered on 24 Aug 2012, 11:17 AM
Hello James and Mark,

I have the same kind of problem with the Q2 2012 release.
This kind of binding only seems to initially disable the input element. When changing the viewmodel, the disabled attribute doesn't automatically change.

You can, however, customize the binders to make it work. E.g.:
kendo.data.binders.disabled = kendo.data.Binder.extend({
    refresh: function() {
        var element = $(this.element);
        var disabled = this.bindings["disabled"].get();
        if (disabled) {
            element.attr("disabled", "disabled").addClass("k-state-disabled").removeClass("k-state-focused");
        } else {
            element.removeAttr("disabled").removeClass("k-state-disabled");
        }
    }
});

Best Regards,
Wannes.
0
tahmed
Top achievements
Rank 1
answered on 28 Mar 2014, 05:02 AM
Is this issue resolved in latest release of Kendo UI.

Thanks,
Sudhir
Tags
MVVM
Asked by
James
Top achievements
Rank 1
Answers by
Marc
Top achievements
Rank 1
Wannes
Top achievements
Rank 1
tahmed
Top achievements
Rank 1
Share this question
or