I found this jQuery Plugin online. The plugin is exactly what I need and I want to add it to my page but my table is created by obtaining the elements from a db. I tried adding it to the page as the jsFiddle sample but pagination just does not show. The only change I am making to the jsFiddle code is the instead of breaking the pages every tbody element I want it to break it every tr element. Here is the code for the table, any suggestion is welcomed.
var columns = ["username", "user_id", "address", "state", "postal_code", "phone", "email"];
var level_classes = {
"NEW": "new_client",
"RENEWAL": "renewing_client",
"CURRENT": "current_client"
};
$(document).ready(function() {
$.getJSON("obtainUsers.php", function(data) {
var $table = $('<table style="width: 100%;">');
var $tbody = $('<tbody>');
$table.append($tbody);
var $tr = null;
data.forEach(function(user, index) {
if (index % 4 === 0) {
$tr = $('<tr>');
$tbody.append($tr);
}
$td = $('<td class="' + level_classes[user.level] + '">');
columns.forEach(function(col) {
$td.append(user[col]);
$td.append($('<br>'));
});
$tr.append($td);
});
$('.runninglist').append($table);
});
});
I have never used a plugin before, so any suggestions will be greatly appreciated.
Thank you