Conditional in template not working

2 posts, 0 answers
  1. Chris
    Chris avatar
    1 posts
    Member since:
    Jan 2012

    Posted 03 Feb 2012 Link to this post

    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>
                        #= message #
        # } elseif (type == 'error'){ #
                <div class='alert-message error'>
                    <a class="close" href="">x</a>
                        #= message #
        # } #

    Any help would be greatly appreciated! Thanks!

  2. Georgi Tunev
    Georgi Tunev avatar
    7207 posts

    Posted 06 Feb 2012 Link to this post

    Hi Chris,

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

    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!
Back to Top