Created
December 24, 2008 20:02
-
-
Save stefanpenner/39758 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> | |
<script type="text/javascript" src="jquery-1.2.6.js"></script> | |
<script type="text/javascript"> | |
// tablelize | |
(function($){ | |
$.fn.tablize = function(){ | |
var store = new Array(); | |
var toText = function(){ return $(this).text(); }; | |
// function to take a tr and map it to a store row | |
var toStoreRow = function(){ | |
var storeRow = new Array(); | |
// stores raw html | |
storeRow.push(this); | |
// stores values in locations 1...n | |
storeRow.concat($(this).map(toText())); | |
return storeRow; | |
}; | |
// ** NOTES ** | |
// $('tr',$('tbody')).map(function(){return $(this).text();}).map(function(){alert(this);}); | |
// ** TODO ** | |
// create a table object | |
// create a row object | |
// var reDrawTable = function(table){}; | |
// var setListeners = function(){}; | |
// on click | |
// - comparator = correct comparator; direction + column knowledge | |
// - store.sortbo(comparator); | |
// - store.redraw(); | |
// | |
// should be in an initializer | |
store = $('tbody tr',this).map(toStoreRow); | |
return this; | |
}; | |
})(jQuery); | |
$('document').ready(function(){ | |
$('#table').tablize(); | |
}); | |
</script> | |
</head> | |
<body> | |
<table id="table"> | |
<thead> | |
<tr> | |
<th>number</th> | |
<th>name</th> | |
<th>html</th> | |
</tr> | |
<tbody> | |
<tr> | |
<td>5</td> | |
<td>stefan</td> | |
<td><b>stefan</b></td> | |
</tr> | |
<tr> | |
<td>-5</td> | |
<td>sam</td> | |
<td><b>sa,</b></td> | |
</tr> | |
<tr> | |
<td>1</td> | |
<td>gip</td> | |
<td><b>gip</b></td> | |
</tr> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment