I have a table with some information. At first time it is generate from php-script and then every n-seconds check database.
Then I've installed tablesorter plugin. It's okay, but now, after getting information from database(if table was sorted by several fields) sort "configuration" resets.
So I've found some information about saveSort plugins, download jquery.tablesorter.widgets.js
include it into my project. In plugin's documentation I've found some instruction like how to
.
$("table").tablesorter({
widgets: ["saveSort"]
});
But it doesn't fix my problem. After getting results the saved sort resets.
So, here is the code of my script:
$(document).ready(function(){
$("table").tablesorter({
widgets: ["saveSort"]
});
function get_op(){
var dataSend = "to teh mooon";
jQuery.ajax({
type: "POST",
url: "get_url",
dataType:"html",
data:dataSend,
success:function(response){
$("#recent_op tbody").html(response);
$("#recent_op").trigger("update");
},
error:function (xhr, ajaxOptions, thrownError){
$("#recent_operations").html(thrownError);
}
});
}
setInterval(function(){get_op()}, 10000);
});
Here is simple table that I used.
<table class="table table-bordered table-hover table-striped tablesorter" id = "recent_op">
<thead>
<tr>
<th>header # <i class="fa fa-sort"></i></th>
....
</tr>
</thead>
<tbody>
<tr>
<td>Body</td>
....
</tr>
....
<tr>
<td>Body</td>
....
</tr>
</tbody>
</table>
So, no errors, everythings from tutorial, but it doesn't work good. I think I'm use this widget in a wrong way.