Created
November 30, 2011 21:38
-
-
Save sbisbee/1411024 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css"> | |
</head> | |
<body> | |
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> | |
<script src="http://autobahn.tablesorter.com/jquery.tablesorter.min.js"></script> | |
<script> | |
function makeTable(parentSelector, colHeaders, data) { | |
var table = $('<table>') | |
.addClass('zebra-stripped') | |
.attr('cellspacing', '0'); | |
table.append( | |
$('<tr>').append( | |
colHeaders.map(function(v) { | |
return '<th>' + v + '</th>'; | |
}).join('') | |
) | |
); | |
$.each(data, function(k, row) { | |
table.append( | |
$('<tr>').append( | |
row.map(function(v) { | |
return '<td>' + v + '</td>'; | |
}).join('') | |
) | |
) | |
}); | |
$(parentSelector).append(table); | |
return table; | |
} | |
$(function() { | |
makeTable('body', [ 'col1', 'col2' ], [ [ 'a1', 'a2' ], [ 'b1', 'b2' ] ]).tablesorter({ | |
sortList: [[1,0]] | |
}); | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment