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

more with nested templates

1 Answer 176 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Stacey
Top achievements
Rank 1
Stacey asked on 04 Nov 2013, 01:15 AM
I have used this before, and it worked, but for some reason it is ceasing to out of nowhere. I have a situation where I am using nested templates like this ...

using the following model, this doesn't display the second level results, for some reason. But SOMETIMES it does. I cannot reproduce the behavior consistently.

{
  "Id": null,
  "Name": "Test Item",
  "Prototypes": [
    {
      "Id": "items/prototypes/shield",
      "Name": "Shield",
      "Mutations": [
        {
          "Name": "Shield",
          "Measurement": 4,
          "Statistic": {
            "Id": "statistics/damage-reduction-physical",
            "Name": "Damage Reduction/Physical"
          }
        },
        {
          "Name": "Shield",
          "Measurement": 15,
          "Statistic": {
            "Id": "statistics/health",
            "Name": "Health"
          }
        }
      ],
      "Consumable": false,
      "Equipable": true,
      "Tags": [
        {
          "Id": "tags/shielding",
          "Name": "Shielding",
          "Description": "This  is capable of somehow shielding the user, either with mitigation or abilities"
        }
      ]
    }
  ]
}
<div
     data-role="listview"
     style="margin: 0px;"
     data-template="templates-admin-inherited-prototypes"
     data-bind="source: Prototypes"></div>
<script type="text/html" id="templates-admin-inherited-prototypes">
    <h2 data-bind="text: Name"></h2>
    <div
         data-template="templates-admin-inherited-mutation"
         data-bind="source: Mutations"></div>
  
</script>
<script type="text/html" id="templates-admin-inherited-mutation">
    ${ Statistic.Name }
</script>

1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 04 Nov 2013, 09:48 AM
Hello Stacey,

I reproduced the problem you describe in the following jsbin. The issue is related to the MVVM bound template having multiple root elements (h2 and div). Wrapping the template contents in a single element resolved the problem. 

Regards,
Petyo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Templates
Asked by
Stacey
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or