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.

Était-ce utile?

La 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);         
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top