Can anyone tell me why my “Id” always gets a zero added at the end? and how to fix that?
<script id="myTemplate" type="text/x-jquery-tmpl">
<tr id='${Id}'>${Id}</tr>
</script>
<div id="tblMyTable"></div>
$(document).ready(function(){
var test = [
{ Id: 43000796568231936 , ReleaseYear: "1998" },
{ Id: 43000796568231937 , ReleaseYear: "1999" },
{ Id: 43000796568231938 , ReleaseYear: "1976" }
];
$("#myTemplate").tmpl(test).appendTo("#tblMyTable");
});
Looks like a JS WTF…
It’s changing your numbers to 43000796568231940.
This happens in Google Chrome, Firefox, and IE.
You can fix this by changing your integers to strings: http://jsfiddle.net/55u9M/16/
Change your JSON from:
To