I have the following html in a website:
<table id="list" class="tablesorter">
<thead id="header">
</thead>
<tbody id="rows">
</tbody>
</table>
I load the header and rows of the table using javascript. Example of how I fill the headers:
$.get( '/getdata',{}, function(mydata) {
// Parses JSON Into Array
var array = $.parseJSON(mydata);
var html = '<tr>';
html+='<th>#</th>';
html+='<th>One</th>';
html+='<th">TOTAL</th>';
var available = {};
for (var i = 0; i < array.length; i++) {
available_item = array[i];
html+='<th><abbr title="'+array[i].text+'"><img src="img/flags2/'+array[i].country+'.png"></img></abbr></th>';
};
html += '</tr>';
$(html).appendTo('#header');
});
The rows are filled in a similar way: ajax get, for loop, and append to html.
Now I need the table columns to be sortable. I was trying to get it work with jquery tablesorter but it is not working. I suppose that it is not working because my data is loaded using javascript.
How can I make this table sortable?
$(html).appendTo('#header');)- I've done this in the past and it works nicely.