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

Forcing MVVM View to update after view-model changes

1 Answer 687 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Jairo
Top achievements
Rank 1
Jairo asked on 23 Jun 2017, 04:27 PM

Hello,

So I read some of the Kendo documentation regarding MVVM and it says that once the view model is updated the view (HTML) should update as well. 

I tried that many times and when I change the viewModel from javascript I don't see the changes updated in the HTML unless I trigger the change event, as shown here:

https://jsfiddle.net/oycbw9e6/

You will notice that if you comment out this line: viewModel.trigger("change", { field: "price"}); then the changes won't be propagated to the HTML view.

Is there any way it can be done automatically without triggering the "change" event?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 27 Jun 2017, 08:09 AM
Hello Jairo,

On the following Dojo example you will find a modified version of your code. You will notice that I have changed the direct assignment of the ViewModel property to use the ObservableObject's set method which has an internal change tracking mechanism. 

In addition to the above, I have added a button with a click event binding, which also changes the value by using the set() method. 

I hope this helps. In case you have any other questions, please do not hesitate to contact us.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
MVVM
Asked by
Jairo
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or