Page MenuHomePhabricator

sorttable.js fails to init for sortable table
Closed, InvalidPublic


Author: alan.harder

I see a couple other bug reports/feature requests about sortable tables, so
clearly it works for some people.. however, on 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"

+ Use XHTML to include js.. with document.write sorttable.js doesn't see
vars/funcs from outside
document.write('<script type="text/javascript"
+var e = document.createElement('script');



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:

var thead = false;

Version: 1.9.x
Severity: normal
OS: Windows XP
Platform: PC



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:35 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz9134.
bzimport added a subscriber: Unknown Object (MLST).

alan.harder wrote:

Oops, just looked at current svn and see this is obsolete.. table sorting stuff
is now all in wikibits.js. Closing.