I can't seem to get Mottie's Tablesorter "emptyTo" to work, sorting works but the empty cells sort to the top which I don't want. I'm not trying to do anything special, I am just sorting regular text and there happens to be empty cells which I'd prefer to sort to the bottom.
I tried using the "emptyTo" tablesorter property from: http://mottie.github.io/tablesorter/docs/example-option-sort-empty.html but empty spaces still sort to the top.
These are the scripts included:
I am using coffeescript:
tableOptions =
emptyTo: 'bottom', //<---- This is the property that should work but isn't :(
showProcessing: true,
widthFixed: true,
widgets: ['zebra', 'stickyHeaders'],
widgetOptions:
stickyHeaders: '',
stickyHeaders_offset: 0,
stickyHeaders_cloneId: '-sticky',
stickyHeaders_addResizeEvent: true,
stickyHeaders_includeCaption: true,
stickyHeaders_zIndex: 2,
stickyHeaders_attachTo: null,
stickyHeaders_filteredToTop: true
stickyHeaders_attachTo: '.scroll'
Then...
$ ->
$('.tablesorter').tablesorter(tableOptions)
My table structure is the standard tablesorter structure:
<table class="tablesorter">
<thead>
<tr><th></th></tr>
</thead>
<tbody>
<tr><td></td></tr>
</tbody>
</table>
I'm also using bootstrap in this application so I'm not sure if that would affect it in anyway... Let me know if I'm missing something.
The config is correct, it has some redundant settings (i.e. are default anyway), but better be safe than sorry. The comment on line 2 is not valid CoffeeScript syntax, but that's for purposes of posing on Stack Overflow.
Since you've mentioned the table is generated using javascript (or CoffeeScript, it get's down to the same thing), the order of generating data and using tablesorter is important:
If workflow tool is used, such as grunt, gulp etc. and scripts are compiled into a single script it's also important that this order is respected. Both tools listed have a way of specifying order of including scripts.