Consider the following code. Within the incidentPercentage method, I am using another dependent method, but I am not able the use the recommended "this.get" syntax here. The only way I could get it to work was to call the other dependent methods directly. Please advise. Is this OK to do?
var viewModel = kendo.observable({
dataItem: {},
details: function() {
return this.get('dataItem').details;
},
hourCount: function() {
var dataItem = this.get('dataItem');
return (dataItem.hasOwnProperty('status') ? dataItem.status.length : 0);
},
incidentCount: function() {
return _.without(this.get('dataItem').status, 1, true).length;
},
incidentPercentage: function() {
return Math.round(
this.incidentCount() / this.hourCount() * 100
);
}
});
var viewModel = kendo.observable({
dataItem: {},
details: function() {
return this.get('dataItem').details;
},
hourCount: function() {
var dataItem = this.get('dataItem');
return (dataItem.hasOwnProperty('status') ? dataItem.status.length : 0);
},
incidentCount: function() {
return _.without(this.get('dataItem').status, 1, true).length;
},
incidentPercentage: function() {
return Math.round(
this.incidentCount() / this.hourCount() * 100
);
}
});