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

Conditional in template not working

1 Answer 132 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 03 Feb 2012, 04:51 PM


Hey guys, I am trying to use conditionals in my template and it keeps blowing up (Invalid template error). Here is what I have

Here's the data:
var data = { type: 'success', message: 'A new contact was created!'};


Here's the template:
<script id="alert-template" type="text/x-kendo-template">
 
    # if (type == 'success'){ #
 
            <div class='alert-message success'>
                <a class="close" href="">x</a>
                <p>
                    #= message #
                </p>
            </div>
 
    # } elseif (type == 'error'){ #
 
            <div class='alert-message error'>
                <a class="close" href="">x</a>
                <p>
                    #= message #
                </p>
            </div>
 
    # } #
 
</script>

Any help would be greatly appreciated! Thanks!






1 Answer, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 06 Feb 2012, 10:22 AM
Hi Chris,

There is no elseif in JavaScript. The correct syntax is else if.


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