When is javascript within a template executed? Is it rendered every time the data binding occurs or is it only once?
Example -
So I want to show ID field when person object is missing in the JSON data. I get following error when I run it - "person variable is missing"
How do I handle missing variables in templates? How can I check for them?
Example -
<script id=
"demoTemplate"
type=
"text/x-kendo-template"
>
#if(person) {
<h1>${person.name}</h1>
}
else
{
<h1>${id}</h1>
}
#
</script>
<script>
var data = [{
"person"
:{
"name"
:
"saurabh"
},
"id"
:123},{
"id"
:123}]
window.kendoMobileApplication =
new
kendo.mobile.Application(document.body);
$(document).ready(
function
() {
$(
"#listUL"
).kendoMobileListView({
template: $(
"#demoTemplate"
).text(),
dataSource: data
});
}
</script>
So I want to show ID field when person object is missing in the JSON data. I get following error when I run it - "person variable is missing"
How do I handle missing variables in templates? How can I check for them?