nathanbweb nathanbweb - 1 year ago 87
Javascript Question

Use tablesorter jQuery plugin with YQL-generated table

I'm trying to use the tablersorter jQuery plugin (, but I can't get it to work with a table that's dynamically populated via YQL from a Google Doc (using Christian Heilmann's example)

I'm trying to do something like this:


Name Team Position Time Shots six seven eight
Abdoun Algeria Midfielder 16 0 6 0 0
Abe Japan Midfielder 351 0 101 14 0
Abidal France Defender 180 0 91 6 0

I have tablesorter working in this example with a static table:

What am I doing wrong?

Answer Source

You should put $("#results").tablesorter(); inside getJSON callback function, not after it. You are calling tablesorter() on results table before it is created.

Edit: You should also change <td> elements to <th> elements inside <thead> for sorting to work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download