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

Question about accessing a hierarchic observable

1 Answer 42 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Randall
Top achievements
Rank 1
Randall asked on 14 Oct 2014, 05:52 PM
I have a hierarchic javascript object that I pass to kendo observable. Is it better to use get and set on the top-level object with dotted path into the object?
    viewModel.get('current.prType');


Or is it better to use get and set on the lowest level of the hierarchy?
    viewModel.current.get('prType');

Here is a simple jsfiddle sample that demonstrates that both forms work. I just want to know if there is any difference that I should be aware of.

http://jsfiddle.net/ebLxk7at/


Thanks,
randall.

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 16 Oct 2014, 01:49 PM
Hello Randall,

Using the full path is preferred. The other approach works because MVVM in some scenarios needs to search in depth to find such property.

Here is another example that should show you better the difference.

http://jsfiddle.net/ebLxk7at/1/


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