templates with localized data - Uncaught Error: Invalid template:

3 posts, 0 answers
  1. Ed
    Ed avatar
    168 posts
    Member since:
    Sep 2013

    Posted 04 Sep 2014 Link to this post

    Here's my template (from my .cshtml file):

    <script id="row-checkbox-template" type="text/x-kendo-tmpl">
        <div style="text-align:center;">
        <input type="checkbox" class="chkRow" data-id="#=TransactionId#" #if (!IsEditable) {# disabled="disabled" #} else {# tabindex="0" #}# title="@AssignCategories.SelectRow" />
        </div>
    </script>

    In en-US locale, all works great, now I'm testing fr-CA and I'm getting "Uncaught Error: Invalid template."  I remove the localized text from the title attribute in the template and it works great.  BTW, the fr-CA value for the title that is causing the issue is: "Sélectionner une ligne".

    How do I properly encode this value in the template?

    Thanks,
    --Ed
  2. Ed
    Ed avatar
    168 posts
    Member since:
    Sep 2013

    Posted 04 Sep 2014 in reply to Ed Link to this post

    and here is the exception (in the Chrome Console):

    Uncaught Error: Invalid template:'
        <div style="text-align:center;">
        <input type="checkbox" class="chkRow" data-id="#=TransactionId#" #if (!IsEditable) {# disabled="disabled" #} else {# tabindex="0" #}# title="S&#233;lectionner une ligne" />
        </div>
    ' Generated code:'var o,e=kendo.htmlEncode;with(data){o='\n    <div style="text-align:center;">\n    <input type="checkbox" class="chkRow" data-id="'+(TransactionId)+'" ';if (!IsEditable) {;o+=' disabled="disabled" ';} else {;o+=' tabindex="0" ';};o+=' title="S&';233;lectionner une ligne" />
        </div>
    ;o+=;}return o;' 
  3. Kendo UI is VS 2017 Ready
  4. Ed
    Ed avatar
    168 posts
    Member since:
    Sep 2013

    Posted 04 Sep 2014 in reply to Ed Link to this post

    Fixed the problem using Html.Raw like this...

    @Html.Raw(AssignCategories.SelectRow)
Back to Top