views:

17

answers:

1

Hi,

I have a problems with the JQuery tablesorter plugin.

I use "zebra" widget, but it doesn't work if i have another table in the main table.

$("#selection_table").tablesorter(
     {
          widgets: ['zebra']
        })

if i have another table somewhere in the selection_table, zebra widget stop working properly.

Is there a way to fix such behavior?

Thanks much

A: 

Not sure what you can do here, the code isn't correct, here's the widget:

ts.addWidget({
    id: "zebra",
    format: function(table) {
        if (table.config.debug) {
            var time = new Date();
        }
        $("tr:visible", table.tBodies[0]).filter(':even').removeClass(table.config.widgetZebra.css[1]).addClass(table.config.widgetZebra.css[0]).end().filter(':odd').removeClass(table.config.widgetZebra.css[0]).addClass(table.config.widgetZebra.css[1]);
        if (table.config.debug) {
            $.tablesorter.benchmark("Applying Zebra widget", time);
        }
    }
});

that $("tr:visible", table.tBodies[0]) should be: $(table.tBodies[0]).children("tr:visible") to do odd/even correctly.

Nick Craver