Kendo Template error - cannot call method "replace" of undefined

2 posts, 0 answers
  1. AP
    AP avatar
    3 posts
    Member since:
    Jan 2013

    Posted 11 Jan 2013 Link to this post

    Hello, 

    I have a template defined as:
    <script id="roiTemplate" type="text/x-kendo-template">
            <div id="roi" class="span2 offset1 kpi">
                <p>#=title#</p>
                <input type="text" data-width="100" value="#=value#" class="dial" data-readOnly="true"/>
            </div>
    </script>

    And here I'm invoking the template and providing it data:
    var getTemplate = kendo.template($('#roi').html());
    var data = { value : "50", title: "ROI"};
    $('#campaign-metrics').append(getTemplate(data));

    When I load this page, I get the error "Uncaught TypeError: Cannot call method 'replace' of undefined" kendo.all.js at line 252." What am I doing wrong?

  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 11 Jan 2013 Link to this post

    Hello,

     The id of your template is "roiTemplate" yet you call $("#roi") which probably returns nothing. Fix the id of your template.

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
Back to Top