Question

Hi I have defined a jsRender template to create a table dynamically.

<script type="text/x-jsrender" id="tmpl">
<tr>
<td>....</td>
<td>{{:Name}}</td>
</tr>
</script>

In the first table data element I would like to append the value of a hidden input field with id="personId".

How I could do this.

Thanks in advance for any response.

Was it helpful?

Solution

You need to get value of your hidden input field before rendering template.

For example....

function draw()
{
    var data={ Name : 'Peter', FirstTdValue : $("#personId").val()};
    var template = $.templates("#tmpl");
    var htmlOutput = template.render(data);
    $("#result").html(htmlOutput);         
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top