By dynamic I mean that I don't know what is the data returned from the ajax response. I managed to return {name:"" value:""}
pair for some leverage.
sample data:
[
[
{
"name": "_id",
"value": "5a32391133425e1f5436161b"
},
{
"name": "Issue",
"value": "Splash Screen Animations"
},
{
"name": "Status",
"value": "Done"
},
{
"name": "Comment",
"value": "The animation must be the same as ios"
}
],
[
{
"name": "_id",
"value": "5a32391133425e1f5436161c"
},
{
"name": "Issue",
"value": "Live Streaming Title and Image"
},
{
"name": "Status",
"value": "Done"
},
{
"name": "Comment",
"value": "asdasd"
}
],
]
So How to render these data in a table or handlebars template?. knowing that the name should be in <thead>
and the value should be in <tbody>
I also managed to separate the response data into separate arrays (headers, and data) so I can render the table as following.
<script type="text/html" id="ViewDataTemplate">
<table class="table table-hover">
<thead>
<tr>
{{#each headers}}
<th>{{this}}</th>
{{/each}}
</tr>
</thead>
<tbody>
{{#each data}}
<tr>
{{#each this}}
<td>{{this}}</td>
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
</script>
Please note: that the answer that I'm looking for is not specific to handlebars, html/js should be enough.