KendoUI compued observable

265 Views Asked by At

When this.get('name') is used in a computed observable calling that computed observable results in the error this.get is not a function.

Example: https://dojo.telerik.com/aXupaPog

1

There are 1 best solutions below

0
VladaxLe On

In Javascript this is referes to diffrent objects depending on how a function is called. In your example you are receiving function from view model and then execute it.

 var v = viewModel.get('v')();

In that case this inside function is referes to 'Window' object. To avoid this error you should call function as viewModel member.

 var v = viewModel.v();

or manually set this to viewModel via bind/apply/call methods.

 var v = viewModel.get('v').call(viewModel);