[Mediawiki-l] "Sortable" (Table Sorting) Not working

Jack D. Pond jack.pond at psitex.com
Tue Nov 18 13:31:14 UTC 2008


I probably did something to screw up my wikis, but all of them couldn't use
the standard javascript table sorting function in MediaWiki
(class="sortable).  Thought I'd document a little to save future admins some
work.  If this is a common problem, someone create a bug and I'll look into
fixing it.
 
The symptom was that class="sortable" was being ignored (tables wouldn't
sort).
 
The way you make tables sortable is to add the table to a javascript class
"sortable".  This is done by (example)
 
{| class="sortable"
! ColHdr1
! ColHdr2
|-
| r1c1
| r1c2
|-
| r2c1
| r2c2
|}
 
Table sorting in MediaWiki is done via javascript found in
skins/common/wikibits.js in it's own section.
 
I didn't stop to figure out why it wasn't sorting, I just replaced it with
the original source code, which can be found in
http://www.joostdevalk.nl/code/sortable-table/
 
Once you've copied that source code into wikibits.js, you probably want to
change back to the MediaWiki sort icons:
 
/* You can change these values */
var image_path = stylepath+"/common/images/";
var image_up = "sort_up.gif";
var image_down = "sort_down.gif";
var image_none = "sort_none.gif";

In addition you shoudl comment out the following line (already done for you
later with addhook)
 
addEvent(window, "load", sortables_init);
 
Hope this helps someone!
 
Jack

 
 
 


More information about the MediaWiki-l mailing list