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

BUG REPORT - Grid Custom Editor Template JavaScript comments would throw error

1 Answer 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peng
Top achievements
Rank 1
Peng asked on 21 Mar 2017, 08:42 PM
How to reproduce.

 

Have a Grid setup,

Use Template like this.

.Editable(e => e.Mode(GridEditMode.PopUp).TemplateName("Example"))

Inside Example Template

Get something like this to the bottom of the page other than your normal input:

<script>
    $(document).ready(function () {
        setTimeout(function () {
            // comments that will cause problem
            if ($("#hideClassId").val() > 0) {
                $("#tClassId").hide();
                $("#tClass").show();
            }
        });
    });
 
    // comments that can cause problem
    $("input#IsActive").on('change', function () {
        $('#ActiveWaiting').prop('checked', false);
    });
 
    // comments that can cause problem
    $('#ActiveWaiting').on('change', function () {
        $("input#IsActive").prop('checked', false);
    });
</script>

 

Then the popup would freeze.
This is what the error would look like in the console.

Uncaught SyntaxError: Unexpected end of input
    at eval (<anonymous>)
    at Function.globalEval (https://kendo.cdn.telerik.com/2017.1.223/js/jquery.min.js:2:2662)
    at n.fn.init.append (https://kendo.cdn.telerik.com/2017.1.223/js/jquery.min.js:3:22791)
    at M.fn.init.n.fn.(anonymous function) [as appendTo] (https://kendo.cdn.telerik.com/2017.1.223/js/jquery.min.js:3:24510)
    at init._createPopupEditor (https://kendo.cdn.telerik.com/2017.1.223/js/kendo.all.min.js:49:21766)
    at HTMLAnchorElement.<anonymous> (https://kendo.cdn.telerik.com/2017.1.223/js/kendo.all.min.js:49:27635)

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 23 Mar 2017, 01:38 PM
Hello Peng,

The issue occurs because the content of the template is compressed to only one line, and the comment is interfering with the parsing.

This is expected and can be avoided using the other comments syntax. Please have in mind that this is not considered as a bug the // symbols are interfering with the parsing:

/*Custom comment*/
 
$('#grid').customFunction()

I hope this is helpful.

Regards,
Stefan
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Peng
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or