Tablesorter zebra widget breaks sortability

Go To StackoverFlow.com

0

I have put this code together to create a table, but when I include the zebra widget - I can only sort the columns to descend. I cannot make the ascend or bring them back to normal, however the zebra widget works :D

Is there anything wrong with my code here? Thanks :)

    $(document).ready(function() { 

         $("#myTable").tablesorter({  

         $("table").tablesorter({ 
         widgets: ['zebra','repeatHeaders'] 
         }); 
});

Edit: I also tried changing 'table' to '#myTable'.

2011-10-20 13:36
by pufAmuf


1

Why do you open it twice?

It should be

$(function() {      
    $("#myTable").tablesorter({widgets: ['zebra']});
});
2011-10-20 13:41
by Marco Johannesen
Hmmm, I don't know why it never occurred to me. Thanks Marco : - pufAmuf 2011-10-20 13:45
Heheh... Anytime : - Marco Johannesen 2011-10-20 14:21


1

You will need to add the widget in as described here and then call it like so:

$(document).ready(function() 
    { 
        // Sort Specific Table //
        $("#myTable").tablesorter();

        // Sort Specific Table and Add Zebra to it only //
        $('#myTable').tablesorter({widgets: ['zebra','repeatHeaders']});

        // Add Zebra Plugin to All Tables //    
        $("table").tablesorter({ 
            widgets: ['zebra','repeatHeaders'] 
        });
    } 
); 
2011-10-20 13:43
by dSquared