質問

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.

役に立ちましたか?

解決

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);         
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top