jennschiffer / timbles.js

a very simple jQuery plugin for tables, made by the person who literally did not invent tables
MIT License
38 stars 4 forks source link

Separating sortColumn into event handler and user-callable #7

Closed edelooff closed 8 years ago

edelooff commented 9 years ago

This is not really an enhancement suggestion rather than a way to discuss some enhancements I'm working on but aren't quite ready for a proper PR yet. These changes can be viewed in the branch event-refactor.

The sortColumn function has been renamed and reworked to strictly provide the event handling code for a sort. That is, it accepts an event with a target and a sort order. This function is not intended to be called by user code. What this does it make the enableSorting method a little simpler, removing the nested function.

The new sortColumn function does the same thing as before, it accepts a <th> ID as string and a sort order and will trigger the sort on the associated column. It also accepts a numeric (0-based) column reference, allowing for a simple "sort the second column descending" via .timbles('sortColumn', 1, 'desc').

edelooff commented 8 years ago

Resolved by #9