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

2 posts, 0 answers
  1. Peng
    Peng avatar
    13 posts
    Member since:
    Aug 2010

    Posted 21 Mar Link to this post

    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)
  2. Stefan
    Admin
    Stefan avatar
    1007 posts

    Posted 23 Mar Link to this post

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