Custom template with in-line javascript comments causes error

6 posts, 0 answers
  1. Mike
    Mike avatar
    9 posts
    Member since:
    Apr 2011

    Posted 17 Nov 2016 Link to this post

    Hello,

    After spending a couple of hours trying to figure out why my custom popup editor template was failing with this javascript error in the kendo.all.min.js file: "0x800a03f1 - JavaScript runtime error: Expected '}' "

    it turned out to be an inline javascript comment that was causing the error.  I have a script tag at the top of my template with a couple of javascript functions and in them are some single-line comments using the '//' syntax.  When I remove those the popup editor works just fine and when I put them back in it throws the error. Why is this happening? Is this a known issue? Is it documented anywhere?

     

    Thanks,

    Mike

     

     

  2. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 21 Nov 2016 Link to this post

    Hello Mike,

    I assume the cause for this issue is that you are using a hash ('#') symbol in the commented code which should be escaped. Please check out the following help article which elaborates more on using templates.

    I hope this information helps.

    Regards,
    Kostadin
    Telerik by Progress
    Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
  3. Mike
    Mike avatar
    9 posts
    Member since:
    Apr 2011

    Posted 21 Nov 2016 in reply to Kostadin Link to this post

    Hello Kostadin,

    Actually, in this instance, using a ('#') isn't the problem.  Just using a simple in-line comment causes the popup edit template from loading:

    Putting this at the top of the template will cause the script error. I also tried escaping the comment with no luck. Please try it yourself and see if you get the same results.

    <script>
    function someFunction(e) {
    //some comment
    }
    </script>

     

    Thanks,
    Mike

     

  4. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 23 Nov 2016 Link to this post

    Hello Mike,

    The cause for this issue is that the entire template is rendered on a single line and when using a comment like that tall the code until the end of the row get commented. In case you want to use a comments inside the template you can use the following syntax.
    <script>
    function someFunction(e) {
    /*some comment*/
    }
    </script>

    I hope this information helps.

    Regards,
    Kostadin
    Telerik by Progress
    Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
  5. Mike
    Mike avatar
    9 posts
    Member since:
    Apr 2011

    Posted 23 Nov 2016 in reply to Kostadin Link to this post

    Hi Kostadin ,

    Thanks for the reply and I would like to ask for a feature? Like me, I believe most people are not intimately aware of what's going on under the covers with kendo all the time and I believe this situation is one of them.  It would be nice if kendo could throw a more meaningful error in this situation than the arbitrary one that I sent in my original post. Perhaps some preprocessing of the template to look for this condition and throw an error explaining it.  This would avoid the couple hours of frustration I endured when I hit this error. 

    Thanks,
    Mike

     

  6. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 25 Nov 2016 Link to this post

    Hi Mike,

    I will forward your requirement to our developers and if a more useful information could be set they will include it in some of our future releases.

    Regards,
    Kostadin
    Telerik by Progress
    Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
Back to Top