More sortable tables

That script again. I needed to be able to trigger a sort onload. Posted this to the aforementioned blog as well, but I’ll keep it here for myself.

1
2
3
4
5
6
7
8
9
10
11
12
//this function is passed the ID of one of the TH elements, and triggers a sort without a click
function trigger_Sort(id) {
	var fakeEvent=new Object;
	fakeEvent.currentTarget=document.getElementById(id).firstChild;
//comment out this block for ascending sort
	for (var i=0; i<fakeevent .currentTarget.childNodes.length; i++) {
		if (fakeEvent.currentTarget.childNodes[i].tagName) {
			fakeEvent.currentTarget.childNodes[i].setAttribute('sortdir','down');
		}
	}
	ts_resortTable(fakeEvent);
}

//this function is passed the ID of one of the TH elements, and triggers a sort without a click function trigger_Sort(id) { var fakeEvent=new Object; fakeEvent.currentTarget=document.getElementById(id).firstChild; //comment out this block for ascending sort for (var i=0; i<fakeevent .currentTarget.childNodes.length; i++) { if (fakeEvent.currentTarget.childNodes[i].tagName) { fakeEvent.currentTarget.childNodes[i].setAttribute('sortdir','down'); } } ts_resortTable(fakeEvent); }