-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
default sort on page load ignores direction #30
Comments
Thanks for pointing this out — a CodePen demonstrating the issue would be helpful, and a pull request would be even better because I likely will never have time to patch this myself 😁 |
Thanks for your answer. |
I made a demo on CodePen: http://codepen.io/anon/pen/ozyVXY |
I noticed this too and your fix did fix it! Thanks. |
Experienced the same problem, the proposed code-change fixed it 👍 |
The proposed solution creates a new bug: tablesort.index returns null always. |
Can you be a bit more specific? |
With the proposed solution, this code stop working: tablesort.index is allways null: $('#userList').on('tablesort:complete', function(event, tablesort) { |
Sorry, but I can't reproduce your problem. |
I added my code to your CodePend demo, please check it here: |
You are right! I think this should solve the problem: |
Ok, it's working. But now, when you click on a column, the default sort is DESC, before was ASC. |
Just rename the "asc" to "desc" on line 44. |
Your solution is working now. Thank you. |
You'r welcome. |
A descent sorting on page load seems impossible because of the check for a different column.
The sort function with direction 'desc' still sorts the column in ascending order:
$('table.sortable').tablesort().data('tablesort').sort($("th.default-sort"), 'desc');
Changing the following line fixed that issue for me:
https://github.com/kylefox/jquery-tablesort/blob/master/jquery.tablesort.js#L42
from
if (this.index !== th.index()) {
to
if (this.index !== null && this.index !== th.index()) {
The text was updated successfully, but these errors were encountered: