A follow up to this. I'm seeing some really odd behavior now. Here is the code that populates the table.
function fillTable() {
$.ajax({
url: "./UserServlet?action=all",
cache: false,
dataType: "json",
async: false,
success: function(data) {
$('#usertable tbody').empty();
$.each(data, function(k,v) {
var firstname = (v.firstname) ? v.firstname : 'FirstName';
var lastname = (v.lastname) ? v.lastname : 'LastName';
var email = (v.email) ? v.email : 'EMail';
var firm = (v.firmname) ? v.firmname : 'Firm';
$('#usertable tbody').append(
"<tr style='cursor: pointer;' onclick='editUser(\""+email+"\")'>" +
"<td>" + firstname + "</td>"+
"<td>" + lastname + "</td>"+
"<td>" + email + "</td>"+
"<td>" + firm + "</td>"+
"</tr>"
);
$("#usertable").trigger("update");
});
}
});
$("#usertable").tablesorter().tablesorterPager({container: $("#pager")});
}
And here is my ready function:
$(document).ready(function(){
$("#usertable").tablesorter();
$("#edituser").dialog({
autoOpen: false,
modal: true,
buttons: {
"Save": function() {
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
}
});
});
If I click the link that populates the table once I am still getting all of the records returned. However, if I click it a second time the pager is working perfectly and so is the tablesorter. It's very odd.
Here is the html that builds the initial table and the pager.
<table id="usertable" class="tablesorter" border="0" cellpadding="0" cellspacing="1">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Firm Name</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div id="pager" class="pager">
<form>
<img src="images/arrow_scroll_left.png" class="prev"/>
<input type="text" class="pagedisplay"/>
<select class="pagesize">
<option selected="selected" value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
</select>
<img src="images/arrow_scroll_right.png" class="next"/>
</form>
</div>
Any suggestions?