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

Conditional template

1 Answer 207 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 2
Ian asked on 25 Jul 2013, 10:27 PM
In my Tool Tip Target I specify if the type is an image or not:

<a  data-type="image" data-popup="AccountExample.jpg" href="#" data-role="tooltip">
Blah Blah
</a>

In my ToolTip template I need to show the image if data-type="image" otherwise just the text in data-popup.

The problem is that the tool tip is always empty. If I just replace the entire template with #=target.data('popup')# the text appears so I know the tool tip is working.
<script id="pop-template" type="text/x-kendo-template">
    #if(target.data('type')=='image'){#
       <img src='@Url.Content("~/Content/images/")#=target.data('popup')#'>
    #}else{#
       #=target.data('popup')#
    #}#
</script>

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 29 Jul 2013, 07:22 AM
Hello Ian,

The provided code snippet works as expected on my side. Please check the generated markup and make sure the resulting image URL is correct. You can add a debugger; statement inside the template script and break to check all expressions inside the template.

If you are using an XHTML DOCTYPE, the <img /> tag should be self-closed, although this is not likely to be the root cause of the problem.

If the problem persists, please send a runnable example for further inspection.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Templates
Asked by
Ian
Top achievements
Rank 2
Answers by
Dimo
Telerik team
Share this question
or