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

Nested values trigger events more than once

1 Answer 106 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 19 Feb 2013, 02:34 PM
The viewmodel's 'change' (and possibly other events) trigger more than once if a nested value is changed. The event appears to be triggered once per nested level. So changing 'nested.value' triggers twice and changing 'very.deeply.nested.value' triggers four times.

I prepared a very simple example at http://jsfiddle.net/eMATB

Am I doing it wrong or is it a kendo bug?

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 21 Feb 2013, 10:40 AM
Hi Thomas,

Thank you for getting in touch with us.

The behaviour you described is expected. Changing the nested field will trigger the change event of its parent observable object which is caught by the change event handler of the View-Model.
If you want to listen for the change of a specific field, you may hook up to the change event of it's parent. As an example:
viewModel.very.deeply.nested.bind("change", function(e) {
    //do stuff 
});

I hope this information will help.

Kind regards,
Alexander Valchev
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
Thomas
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or