Im having an issue where I am trying to create a calculated property on a child object in the observable view model where its value is dependant on a property on the parent and the calculated value is not updating when the parent gets updated.
Please help, Im quite confused
Here is the code and a fiddle of it
https://jsfiddle.net/80mo1ch7/
<
script
>
var viewModel = null;
$(document).ready(function () {
viewModel = kendo.observable({
parentNumber: 1,
child: { showLink: function () { return this.get('parent().parentNumber') == 2 } }
});
kendo.bind($('#simpleTest'), viewModel);
document.getElementById('changeValue').onclick = function () {
if (viewModel.parentNumber == 1)
viewModel.set('parentNumber', 2);
else
viewModel.set('parentNumber', 1);
}
});
</
script
>
<
section
id
=
"simpleTest"
>
<
p
data-bind
=
"text: parentNumber"
></
p
>
<
section
data-template
=
"simpleTestChildTemplate"
data-bind
=
"source: child"
/>
</
section
>
<
script
id
=
"simpleTestChildTemplate"
type
=
"text/x-kendo-template"
>
<
section
>
<
button
id
=
"changeValue"
>Change</
button
>
<
a
data-template
=
"headerTemplate"
data-bind
=
"visible: showLink"
>BlahBlah</
a
>
</
section
>
</
script
>