Fixed failing sorts after multiple calls to makesortable and extended matches for percent values#11
Conversation
1. Fixed issue where sort would work only once for each column, after updating table content dynamically. Reason: multiple handlers were stacked if makesortable was called several times on same table (or when makesortable called before init). 2. Fixed issue where "num %" values would not be sorted correctly due to space chars before %. 3. Reverse sort activated by default (using mostly percentages).
retro-fit current github version and remove reverse patch
|
There may be a documentation bug here; one doesn't need to call |
|
Thanks for your fast answer! Sure
Another workaround would be to add specific code in my |
Reason: multiple instances of same handler were stacked if makesortable is called several times without resetting the TH elements. This also happens if makesortable is called manually before init(). Typically the same handler could be registered twice and therefore cancelling the sort!
Solution: no need to unregister the current handler. This can be managed very nicely giving a reference to a unique function (not anonymous) when calling addEventListener. See section "Multiple identical event listeners" here:
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener