M S.
M S.

Reputation: 21

Tablesorter live content from php sorting jquery

I have a table that looks like this:

Title | Price

A

B

C

I get the title from mysql and the price comes from php script.

My jquery for Price column looks like this:

<script type="text/javascript" >
$(function() { 
var price = setInterval(function()
{
$('#A').load('live_price.php?title=A').fadeIn("slow");

},6000);
});
<script>

live_price.php does all the crunching and spits out a number.

Now, in this case, price update every 6 seconds and updates each row. My problem has to do with sorting this new content.

I tried using:

$("table").trigger("update"); and

$("table").trigger("sorton",[sorting]); without any success. Please help

Upvotes: 1

Views: 479

Answers (2)

Mottie
Mottie

Reputation: 86413

Maybe what you want is to use the "updateCell" method. It isn't documented, but it exists. I made a blog post showing how to use it.

Also, if you are interested, I've forked a copy of tablesorter on github and made some improvements to the plugin. I even included automatically resorting the table after updates - here is the updateCell demo page - click inside any cell in the "Total" column to see it work.

Upvotes: 0

hcker2000
hcker2000

Reputation: 615

See here for the docs.

I think you may just be forgetting to set the sorting order.

var sorting = [[2,1],[0,0]]; 

Before calling

$("table").trigger("sorton",[sorting]);

The other issue may be that .load is destroying all the data in the table. You may need to re-initialize the plugin every time after the table is populated with the new data.

Upvotes: 1

Related Questions