From 0688fcfcf8d5bb8548dc6a80a8f89f66b374dd63 Mon Sep 17 00:00:00 2001 From: Mottie Date: Thu, 3 Jul 2014 17:52:10 -0500 Subject: [PATCH] Docs: show more event parameters & add missing initialized callback function --- docs/index.html | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/docs/index.html b/docs/index.html index 7f4e47a6..aaedc167 100644 --- a/docs/index.html +++ b/docs/index.html @@ -969,6 +969,33 @@ + + + Function + null + This callback fires when tablesorter has completed initialization. (v2.2). +
+
$(function(){
+
+  // bind to tablesorter-initialized event BEFORE initializing tablesorter
+  $("table")
+    .bind("tablesorter-initialized",function(e, table) {
+      // do something after tablesorter has initialized
+    });
+
+  // initialize the tablesorter plugin
+  $("table").tablesorter({
+    // this is equivalent to the above bind method
+    initialized : function(table){
+      // do something after tablesorter has initialized
+    }
+  });
+
+});
+ + + + Boolean @@ -4239,8 +4266,8 @@ $('table').trigger( 'search', [['', '', '', '', 'orange']] ); // find orange in - - + + This event fires when tablesorter has completed initialization. (v2.2).
$(function(){
@@ -4387,7 +4414,7 @@ $('table').trigger( 'search', [['', '', '', '', 'orange']] ); // find orange in
 				Event triggered when the filter widget has finished processing the search (v2.4).
 					

You can use this event to do something like remove the class added to the filter row when the filtering started. Use it as follows:
$(function(){
-  $('table').bind('filterEnd', function(){
+  $('table').bind('filterEnd', function(event, config){
     $(this).find('tr.tablesorter-filter-row').removeClass('filtering');
   });
 });
@@ -4932,6 +4959,8 @@ $('.tablesorter')[0].config.cache[0].normalized[0]; });

If using the pager plugin or widget, the value returned from the filterEnd event will not be accurate, so you'll need to bind to the pagerComplete event instead:
$('table').bind('filterEnd pagerComplete', function(event, data){
+    // Note: data = table.config (filterEnd event); and data = table.config.pager (pagerComplete event)
+    // both objects contain data.filteredRows & data.totalRows
     $('.filter-rows').html( data.filteredRows );
     $('.total-rows').html( data.totalRows );
 });
@@ -5032,6 +5061,8 @@ var wo = $('#mytable').data('tablesorter').widgetOptions; });
If using the pager plugin or widget, the value returned from the filterEnd event will not be accurate, so you'll need to bind to the pagerComplete event instead:
$('table').bind('filterEnd pagerComplete', function(event, data){
+    // Note: data = table.config (filterEnd event); and data = table.config.pager (pagerComplete event)
+    // both objects contain data.filteredRows & data.totalRows
     $('.filter-rows').html( data.filteredRows );
     $('.total-rows').html( data.totalRows );
 });
@@ -5120,7 +5151,7 @@ for (tbodyIndex = 0; tbodyIndex < tbodies.length; tbodyIndex++) { All this function does is add or remove a class name of "tablesorter-processing" and the class name contained within the cssProcessing option.

Here is a basic example of how this function is used: -
$('table').bind('sortBegin sortEnd', function(event){
+						
$('table').bind('sortBegin sortEnd', function(event, table){
 	// this is included with the basic functionality of tablesorter
 	$.tablesorter.isProcessing( this, event === 'sortBegin' );
 });