you need to make your addWidget method handle a function as an argument, and then execute the function if it is supplied and a function...
function foo(bar,callback) { $(bar).remove(); callback && $.isFunction(callback) && callback(); } foo("#baz",function() {alert("done!");}); // removes baz and then says "done" foo("#baz"); // just removes baz. On Oct 4, 9:55 am, Issac Kelly <[EMAIL PROTECTED]> wrote: > I'm working on Christian Bach's tablesorter. > > I've made a widget that can select rows, and now I want to make a > widget that can delete rows, and have a callback. > > The problem is the callback. > > The widgets are called like this > > $.tablesorter.addWidget({ > // give the widget a id > id: "selectRows", > // format is called when the on init and when a sorting has > finished > format: function(table) > { > $("tbody tr",table).click(function(e){ > row = this; > if($(row).hasClass('selectedRow')) > $(row).removeClass('selectedRow'); > else > $(row).addClass('selectedRow'); > }); > } > }); > $.tablesorter.addWidget({ > // give the widget a id > id: "deleteRows", > // format is called when the on init and when a sorting has > finished > format: function(table) > { > if($("tfoot",table).length) > { > //add the foot > $(table).append("<tfoot></tfoot>"); > } > //add a row. > $("tfoot",table).append("<tr class=\"deleteRow\"><a > href=\"#\" > class=\"deleteRows\">Delete selected entries</a>"); > > $(".deleteRows").click(function(){ > $(".selectedRow",table).each(function(){ > $(this).remove(); > ///I WANT A CALLBACK HERE > }); > }); > } > }); > > $("table").tablesorter({ > widgets: ['selectRows','deleteSelected'] > }); > > So, the widgets are called via a text array. How could I add a > callback to a widget?