Christian
Christian

Reputation: 43

Sortable table not working

On http://www.elitedeafpoker.com/dev/poker-players.html - I cant get the sortable table to work. I need some help to make it work.

HTML

<table id="myTable" class="tableData">
    <thead>
        <tr>
            <th>Rank</th>
            <th width="250">Name</th>
            <th>Earnings</th>
            <th>Points</th>
            <th>Total Earnings</th>
        </tr>
    </thead>
    <tbody></tbody>
 </table>

JAVASCRIPT -

$(document).ready(function() { 
    $("#myTable").tableData(); 
} 
);

jQUERY plugin - http://www.elitedeafpoker.com/dev/js/jquery.tablesorter.min.js

All of the codes were referred by http://tablesorter.com/docs/ please let me know what I've missed.

Upvotes: 0

Views: 1598

Answers (3)

shishirmk
shishirmk

Reputation: 425

I would try and use DataTables. The library you are trying to use was last updated in 03-2008 that's almost 5 years ago. In the example The jQuery Version is 1.2. The present version of stable jQuery is 1.9+. There are many changes that are not backward compatible in the intermediate versions.


If you really want just table sorting. If you insist on using just javascript then you could look at this http://www.kryogenix.org/code/browser/sorttable/sorttable.js . The last time I tried it worked fine.

Upvotes: 0

Tim
Tim

Reputation: 779

If I could make a suggestion about libraries, I've used tablesorter before, and eventually switched over to DataTables. Excellent library, with sorting, filtering, etc. built in, and had an awesome, responsive developer, great documentation, and a great community for support.

Upvotes: 0

Ian
Ian

Reputation: 50905

Notice the error in your browser's console: Uncaught TypeError: Object [object Object] has no method 'tableData'

The correct method that the Tablesorter plugin provides is tablesorter, so you want to use:

$("#myTable").tablesorter();

The website link you referenced specifically has this code:

$(document).ready(function() 
    { 
        $("#myTable").tablesorter(); 
    } 
);

If you're using AJAX to load the rows, you need to call:

$("#myTable").trigger("update");

after they are appended.

Upvotes: 1

Related Questions