javascriptjquerytablesorter

Does tablesorter have a onsort event?


I've just downloaded tablesorter and got it up and running.

I need some code to run each time the user sorts the table, and I cant find anything in the documentation :-(

So if anyone know that would be great, thanks!

Is there a event that is triggered each time i sort a column? I need to be the event AFTER the sorting is done


Solution

  • You can bind 'sortEnd' to the tablesorter, see the documentation:

    https://mottie.github.io/tablesorter/docs/example-triggers.html

    from the tablesorter documentation:

    $(document).ready(function() { 
        // call the tablesorter plugin, the magic happens in the markup 
        $("table").tablesorter(); 
    
        //assign the sortStart event 
        $("table").bind("sortStart",function() { 
            //do your magic here
        }).bind("sortEnd",function() { 
            //when done finishing do other magic things
        }); 
    });