Topic on Project:Support desk

Making tables sortable

4
Aeroid (talkcontribs)

Hi,

I'm hacking a little gadget for Wikidata and would like to use "sortable" tables. Just declaring the tables

class="wikitable sortable"

doesn't cut it, as the jQuery events would still need to get registered. Any hint how I could re-do that after I wrote my table into the DOM?

121.220.16.35 (talkcontribs)
Aeroid (talkcontribs)

Thanks, that's the kind of method I was looking for. But it makes it collapsible, not sortable. I was looking looking around in jquery.tablesorter.js for something similar, but there is just nothing like that. Any other suggestion?

Aeroid (talkcontribs)

found it myself...

var sortableTables = $('table.sortable');

if (sortableTables.length) {

mw.loader.using('jquery.tablesorter', function () {

sortableTables.tablesorter();

});

}

Reply to "Making tables sortable"