I am trying to create a template that will read "This template is empty" when the data source is an empty array. Currently, my div is bound to the data source as follows:
<div data-bind="source: data"></div>
I have tried a number of different things including writing a function that returns an object that represents the data source I'm interested in:
function() {
var data = this.data;
if (data.length == 0) {
return [ { dataValue: "This template is empty." } ];
}
else {
return data;
}
};
How would I accomplish this? Thanks in advance.
<div data-bind="source: data"></div>
I have tried a number of different things including writing a function that returns an object that represents the data source I'm interested in:
function() {
var data = this.data;
if (data.length == 0) {
return [ { dataValue: "This template is empty." } ];
}
else {
return data;
}
};
How would I accomplish this? Thanks in advance.