Tablesorter select 2 fix
Select A/B in Name column. It will populate as a selected value
by cwisdo
HTML
<script src="https://mottie.github.io/tablesorter/js/jquery.tablesorter.js"></script>
<link rel="stylesheet" href="http://mottie.github.com/tablesorter/css/theme.blue.css">
<script src="https://mottie.github.io/tablesorter/js/jquery.tablesorter.widgets.js"></script>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.min.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.min.js"></script>
<script src="https://cwisdo.github.io/tablesorter/js/widgets/widget-filter-formatter-select2.js"></script>
<table border="1" class="tablesorter" id="test">
<thead>
<tr>
<th class="filter-onlyAvail">Name</th>
<th>Testing</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>Testing A</td>
</tr>
<tr>
<td>B</td>
<td>Testing B</td>
</tr>
<tr>
<td>A/B</td>
<td>Testing A/B</td>
</tr>
<tr>
<td>A or B</td>
<td>Testing A or B</td>
</tr>
<tr>
<td>A/B</td>
<td>Testing A/B</td>
</tr>
</tbody>
</table>
JavaScript
$(document).ready(function() {
$("#test").tablesorter({
theme: 'blue',
widgets: ['zebra','filter', 'stickyHeaders'],
widgetOptions: {
filter_formatter : {
// Alphanumeric (match)
0 : function($cell, indx) {
return $.tablesorter.filterFormatter.select2( $cell, indx, {
match : false // exact match only
});
}
} //filter?_formatter
} //widgetOptions
});
});