ViewModel, Button and the enabled binding

3 posts, 1 answers
  1. Heath
    Heath avatar
    2 posts
    Member since:
    Mar 2016

    Posted 08 Aug Link to this post

    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. Answer
    Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 10 Aug Link to this post

    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.
     
  3. Kendo UI is VS 2017 Ready
  4. Heath
    Heath avatar
    2 posts
    Member since:
    Mar 2016

    Posted 10 Aug in reply to Ianko Link to this post

    Ahh! I see the nuance now! That did it Ianko, many thanks!
Back to Top