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

Why isn't the the value updating?

2 Answers 100 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Brian Vallelunga
Top achievements
Rank 1
Brian Vallelunga asked on 15 May 2012, 03:47 PM
I have, what I think is a simple MVVM example, where I can't get the displayed value to update. I think there's something very simple I must be missing here.

There's a demo at: http://jsfiddle.net/BrianVallelunga/UzLED/

Basically, I have a view model with a date. I have buttons that change the date. Finally, I have a span bound to a function that formats the date. For some reason the formatted value never changes, despite the date itself changing. Any thoughts?

2 Answers, 1 is accepted

Sort by
0
Brian Vallelunga
Top achievements
Rank 1
answered on 15 May 2012, 10:21 PM
Looking into this more, it seems that Kendo can't tell when a date on a view model is changed. I've updated my example at: http://jsfiddle.net/BrianVallelunga/UzLED/1/ with a new dummy text value that is manually set every time I change the date value. It is also referenced, but not used in the displayCurrentDate function. Adding this, but not using it causes displayCurrentDate to be called and to update the displayed value.
0
Accepted
Atanas Korchev
Telerik team
answered on 16 May 2012, 09:24 AM
Hello,

 Indeed Kendo MVVM cannot detect a change in a Date object itself because JavaScript dates are not wrapped. The way to make it work is to create a new Date object and then update the view model. Here is a sample implementation: http://jsfiddle.net/korchev/QgDED/2/ 

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MVVM
Asked by
Brian Vallelunga
Top achievements
Rank 1
Answers by
Brian Vallelunga
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or