Sortable tables are broken

Marc-Etienne Vargenau <[email protected]> Wed, 10 Jun 2009 14:05:48 +0200
Newsgroups gmane.comp.web.wiki.phpwiki.talk
Organization Alcatel-Lucent (CTO/RDEI/SRA)
Message-ID <[email protected]>
Hello Reini,

Thank you for your correction.

I have another problem with Javascript. The sortable tables no longer work.

You moved the code in ./themes/default/sortable.js
to ./themes/default/wikicommon.js but it seems that you made
some changes that have broken the code.

Original code:

function sortables_init() {
         // Find all tables with class sortable and make them sortable
         if (!document.getElementsByTagName) return;
         tbls = document.getElementsByTagName("table");
         for (ti=0;ti<tbls.length;ti++) {
                 thisTbl = tbls[ti];
                 if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && 
(thisTbl.id)) {
                         ts_makeSortable(thisTbl);
                 }
         }
}

New code:

function sortables_init() {
	var idnum = 0;
	// Find all tables with class sortable and make them sortable
	var tables = getElementsByClassName(document, "table", "sortable");
	for (var ti = 0; ti < tables.length ; ti++) {
		if (!tables[ti].id) {
			tables[ti].setAttribute('id','sortable_table_id_'+idnum);
			++idnum;
		}
		ts_makeSortable(tables[ti]);
	}
}

I get an error: getElementsByClassName is not defined.

Again, this works in Monobook but not in other themes.

Can you please fix?

Best regards,

Marc-Etienne

-- 
Marc-Etienne Vargenau
Alcatel-Lucent France, Route de Villejust, 91620 NOZAY, FRANCE
+33 (0)1 30 77 28 33, [email protected]

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects