Search code examples
jqueryjquery-uijquery-pluginsjquery-loadtablesorter

display loading spinner when a user tries to sort data


I need help modifying my jquery tablesorter plugin.

I am using the plugin located at http://tablesorter.com/docs/

<script type="text/javascript">
    $(document).ready(function() { 
        $('table').tablesorter({
        });
    }); 
    </script> 

I had help from a user and it is working fine now. Since I have large amount of data to sort , it is a bit slow.

So when a user clicks on it I want the user to know it is trying to sort the data. So i want a prompt or something that would show "Loading' or 'Sorting' when or a busy symbol when the sorting is being performed can someone help me with it?


Solution

  • From the documentation:

    $(document).ready(function() { 
        // call the tablesorter plugin, the magic happens in the markup 
        $("table").tablesorter(); 
        //assign the sortStart event 
        $("table").bind("sortStart",function() { 
            $("#overlay").show(); 
        }).bind("sortEnd",function() { 
            $("#overlay").hide(); 
        }); 
    }); 
    

    Explanation: Two callback hooks are implemented by the plugin - sortStart and sortEnd. So in human language, the above code means just before sorting starts show the overlay, and hide it as soon as sorting completes.