Prev | Current Page 751 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

Note, however, that certain elements do not work as
expected with innerHTML in Internet Explorer (the tbody of a table cannot be set in this way for example).
import js.Dom;
typedef Row = { tr : HtmlDom, values : Array < Dynamic > };
typedef DataGrid = Array < Row > ;
class TableSorter
{
private var order : { index : Int, asc : Bool };
private var tbody : HtmlDom;
private var parsers : Array < String - > Dynamic > ;
private var data : DataGrid;
403
Chapter 14: More Interactive Content with JavaScript
public function new()
{
parsers = new Array();
}
public function apply(table : HtmlDom)
{
if(table == null)
throw ???InvalidTable???;
var thead = table.getElementsByTagName(???thead???)[0];
tbody = table.getElementsByTagName(???tbody???)[0];
if(thead == null || tbody == null)
throw ???InvalidTableFormat???;
order = { index : -1, asc : true };
data = null;
var ths = thead.getElementsByTagName(???th???);
var self = this;
for(i in 0...ths.length)
untyped ths[i].onclick = function(e) { self.


Pages:
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763