Reputation: 1622
I am using Mottie's Tablesorter (https://github.com/Mottie/tablesorter) and i am trying to use the Math widget on cells that are formatted like this;
<td data-number="50">Fifty</td>
However i cant seem to find out how to pass data-*
through to arry
on the math-complete
option;
math_complete : function($cell, wo, result, value, arry) {
var txt = '<span class="align-decimal">' +
( value === wo.math_none ? '' : '$ ' ) +
result + '</span>';
if ($cell.attr('data-math') === 'all-sum') {
// when the "all-sum" is processed, add a count to the end
return txt + ' (Sum of ' + arry.length + ' cells)';
}
return txt;
}
Also, I am using v2.18.2.
Upvotes: 2
Views: 500
Reputation: 86433
The math widget is set up to get information from a data-attribute set by the textAttribute
option. So if you want to use data-number
, set that attribute to "data-number"
(demo):
$(function () {
$('table').tablesorter({
theme: 'blue',
textAttribute: 'data-number',
widgets: ['zebra', 'math']
});
});
Upvotes: 1