views:

118

answers:

1

I've found several js table column sorters that work great on regular html content:

http://www.kryogenix.org/code/browser/sorttable/

http://www.allmyscripts.com/Table_Sort/index.html#how_to_use_it

The first one works by assigning a class to a table. The second by passing the id of the table to a js constructor.

I'm using jQuery to handle my ajax request: (the commented code is my attempt at constructing after the ajax loads. It didn't work.)

$("#the_table").load('../ajax/handler.php', {action: 'songs'}, function(){
//var TSort_Data = new Array ('my_table', 's', 's', 'd');
//tsRegister();
});

No errors. The data populates properly. The static html matches the ajax html.

Any ideas?

+1  A: 

The first script runs the init method when the DOM is ready, so to call it after your AJAX loads just call init again.

$("#the_table").load('../ajax/handler.php', {action: 'songs'}, function(){
  sorttable.init();
});
Shawn Steward
Thanks so much!
Stephane