This is a migrated thread and some comments may be shown as answers.

KENDO UI TEMPLATE FUNCTIONING BASIC QUESTION

1 Answer 136 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Saurabh
Top achievements
Rank 1
Saurabh asked on 13 Apr 2012, 06:57 PM
When is javascript within a template executed? Is it rendered every time the data binding occurs or is it only once? 

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?

1 Answer, 1 is accepted

Sort by
0
Saurabh
Top achievements
Rank 1
answered on 18 Apr 2012, 02:07 PM
Could someone at Kendo reply to this? This is critical. How do we handle data if it is null or missing in the binding within a kendo template? 

Saurabh
Tags
Templates
Asked by
Saurabh
Top achievements
Rank 1
Answers by
Saurabh
Top achievements
Rank 1
Share this question
or