datatables and jsrender templates (previously jquery templates)
datatables and jsrender templates (previously jquery templates)
![jeggleston](https://secure.gravatar.com/avatar/3c00abcfefa998d17f56eb7c4c98e91f/?default=https%3A%2F%2Fvanillicon.com%2F3c00abcfefa998d17f56eb7c4c98e91f_200.png&rating=g&size=120)
Hi all,
I'm trying to use jquery templates with datatables. Essentially, I load the table data with a getJSON call, then populate the table with the template render. After the render, I call dataTable on the table. This works for the initial render, but when I sort, all data disappears.
Here's the code, in a nutshell
[code]
{{=data1}}
{{=data2}}
Hello
$(document).ready(function() {
/* Fetch data, and populate table. */
$.getJSON('/api/get_data', function(data) {
$("#tbody_id").html(
$("#tr_template").render(data)
);
} );
/* Apply dataTable. */
$('#table_id').dataTable();
} );
[/code]
Like I said, the table comes up fine initially. But, when I click one of the headers to sort, all the data is lost, and I get "No data available in table".
Any thoughts on what I'm doing wrong?
Thanks,
Joe
I'm trying to use jquery templates with datatables. Essentially, I load the table data with a getJSON call, then populate the table with the template render. After the render, I call dataTable on the table. This works for the initial render, but when I sort, all data disappears.
Here's the code, in a nutshell
[code]
{{=data1}}
{{=data2}}
Hello
$(document).ready(function() {
/* Fetch data, and populate table. */
$.getJSON('/api/get_data', function(data) {
$("#tbody_id").html(
$("#tr_template").render(data)
);
} );
/* Apply dataTable. */
$('#table_id').dataTable();
} );
[/code]
Like I said, the table comes up fine initially. But, when I click one of the headers to sort, all the data is lost, and I get "No data available in table".
Any thoughts on what I'm doing wrong?
Thanks,
Joe
This discussion has been closed.
Replies