Last modified: 2014-08-08 09:08:07 UTC
Steps to reproduce: 1. Create a sortable table (like the one in the provided url) 2. Execute $('table.sortable').clone(true /* = with data and eventhandlers */).appendTo(mw.util.$content); 3. Click the headers of the new table. Expected result: The table sorts correctly. Actual result: An error is thrown: h[list[i][0]] is undefined
I'm not a maintainer of the tablesorter plugin, but I do know (as you've found out) that the sort cache fails when applied to a different table. Work-around: * Don't clone including data and events, you're creating a new table essentially. So call .tablesorter() on it if you want it to be sortable. > $('table.sortable').first().clone().appendTo( mw.util.$content ).sortable()
(In reply to Krinkle from comment #1) > Work-around: > * Don't clone including data and events, you're creating a new table > essentially. So call .tablesorter() on it if you want it to be sortable. > > $('table.sortable').first().clone().appendTo( mw.util.$content ).sortable() Now with mw.hook('wikipage.content') it is possible to do $clone = $('table.sortable').clone(); mw.hook('wikipage.content').fire($clone); $clone.appendTo(mw.util.$content); This seems a reasonable approach to me, and I no longer consider it as just a work-around, but as an actual solution. So let's just close this as WONTFIX.