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

ViewModel, Button and the enabled binding

2 Answers 403 Views
Button
This is a migrated thread and some comments may be shown as answers.
Heath
Top achievements
Rank 1
Heath asked on 08 Aug 2016, 09:46 PM

I'm having an issue with the enabled binding of a button. It's bound to function on a view model (kendo.observable) that returns a Boolean value based on the values of properties on the same view model. The binding runs once, when bound, but never again after the properties of the view model have changed. Is there any way that I can get this binding to 'refresh' on property change? Code below:

var viewModel = kendo.observable({
    userName: null,
    password: null,
    isEnabled: function () {
        var self = this;
 
        return self.userName != undefined && self.password != undefined;
    }
});

And the HTML:

<button class="k-button k-primary" data-bind="click: onClicked, enabled: isEnabled">Click</button>

 

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Ianko
Telerik team
answered on 10 Aug 2016, 07:12 AM

Hello Heath,

The functionality you are after is documented here: http://docs.telerik.com/kendo-ui/framework/mvvm/observableobject#dependent-methods

You should use the dependable method by using the getters of the properties in order for the method to observe the needed properties. Like in this dojo: http://dojo.telerik.com/ePEvi.

Regards,
Ianko
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Heath
Top achievements
Rank 1
answered on 10 Aug 2016, 04:57 PM
Ahh! I see the nuance now! That did it Ianko, many thanks!
Tags
Button
Asked by
Heath
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Heath
Top achievements
Rank 1
Share this question
or