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

Custom template with in-line javascript comments causes error

5 Answers 240 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 17 Nov 2016, 04:45 PM

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

 

 

5 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 21 Nov 2016, 11:40 AM
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.
0
Mike
Top achievements
Rank 1
answered on 21 Nov 2016, 01:26 PM

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

 

0
Kostadin
Telerik team
answered on 23 Nov 2016, 01:14 PM
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.
0
Mike
Top achievements
Rank 1
answered on 23 Nov 2016, 02:20 PM

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

 

0
Kostadin
Telerik team
answered on 25 Nov 2016, 09:19 AM
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.
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Mike
Top achievements
Rank 1
Share this question
or