Skip to content Skip to sidebar Skip to footer

Using A Kendo Observable Property In Multiple Viewmodels

In a Kendo app using the Kendo MVVM framework: I have a 'global' viewModel which is information that is common to all parts of the app - e.g. the UserState, which has a property is

Solution 1:

The problem is that userState is a simple object, not an ObservableObject. Because of this, the change event of the userStateViewmodel observable does not trigger the change event for viewmodel1 and the view doesn't update.

You can remedy this by making userState a property of viewModel1, so it is wrapped in an observable (or you could wrap your return object in the IIFE in an observable):

var viewModel1 = kendo.observable({
    label: 'ViewModel1',
    userState: userState,
    isLoggedInVM1: function() {
        return userState.userStateViewModel.get("isLoggedIn");
    },
    logIn: function ()
    {
        userState.loginUser();
    }          
});

Take a look at this demo; try commenting the userState property and you'll see the difference.

Post a Comment for "Using A Kendo Observable Property In Multiple Viewmodels"