[jQuery] Tablesorter Plugin and widgets
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?