Data binding basics ...

2 posts, 0 answers
  1. Paul
    Paul avatar
    15 posts
    Member since:
    Jun 2014

    Posted 15 Jul 2014 Link to this post

    Hi guys,

    I'm trying to output a template for a panel bar which I want to bind to a simple "Task" object.
    The idea is that I have a kendoPanelbar and a template for adding new campaigns as panels based on a selected task. 
    In short, my task object has a "CampaignId" property and as shown I want to output that value when building the template.
    For some reason though kendo is giving me an error which suggests that it can't find this property.

    Any ideas?

    <script id="campaignContextTemplate" type="text/x-kendo-template">
            <span>Campaign #: CampaignId #</span>
            <div class="campaignTree"></div>

    init code in question:

    var task = $(this);
    var panelTemplate = kendo.template($("#campaignContextTemplate").html());
    var boundResult = panelTemplate(task);
    .... (init tree ect omitted for simplicity) ...

    Chrome tools output:

    [i, jquery: "1.10.2", constructor: function, init: function, selector: "", toArray: function…]
        0: i
           CampaignId: 123
            .... (rest of object output removed) ...
    Uncaught ReferenceError: CampaignId is not defined VM23536:3
  2. Petyo
    Petyo avatar
    2437 posts

    Posted 16 Jul 2014 Link to this post

    Hi Paul,

    I am not sure what is the purpose of this line:

    var task = $(this);

    but most likely wrapping the data object with jQuery is not necessary. Please remove that line and give it a try.

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top