Last modified: 2010-05-15 15:48:27 UTC
I see a couple other bug reports/feature requests about sortable tables, so clearly it works for some people.. however, on codex.gallery2.org we got errors about undefined variables (at least with firefox2). For some reason, sorttable.js couldn't see any vars/funcs from outside when document.write was used in wikibits.js to include sorttable.js. I changed this to use DOM to include the script and this was fixed. Then sorttable.js uses hookEvent to initialize.. but the file isn't included until another hook event is being processed.. seems like this is too late to register a new hook event. I changed this to just call the init function. Seems to work now. Patch below (revision 941 is our own local svn, you can ignore that.. it's mediawiki 1.9.3). Index: skins/common/wikibits.js =================================================================== --- skins/common/wikibits.js (revision 941) +++ skins/common/wikibits.js (working copy) @@ -853,7 +853,9 @@ function sortableTables() { if (getElementsByClassName(document, "table", "sortable").length != 0) { - document.write('<script type="text/javascript" src="'+stylepath+'/common/sorttable.js?1"></script>'); +// Use XHTML to include js.. with document.write sorttable.js doesn't see vars/funcs from outside +// document.write('<script type="text/javascript" src="'+stylepath+'/common/sorttable.js?1"></script>'); +var e = document.createElement('script'); e.src=stylepath+'/common/sorttable.js?1'; document.getElementsByTagName('body')[0].appendChild(e); } } Index: skins/common/sorttable.js =================================================================== --- skins/common/sorttable.js (revision 941) +++ skins/common/sorttable.js (working copy) @@ -19,7 +19,10 @@ var alternate_row_colors = true; -hookEvent( "load", sortables_init); +//This js file is included from an onload handler, adding a handler now won't get it invoked. +//hookEvent( "load", sortables_init); +//Just call the function: +sortables_init(); var SORT_COLUMN_INDEX; var thead = false;
Oops, just looked at current svn and see this is obsolete.. table sorting stuff is now all in wikibits.js. Closing.