Skip to content
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

Overriding the direction parameter #188

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

khamyl
Copy link

@khamyl khamyl commented Jan 21, 2022

If the direction toggle in anchors is not what you want, e.g. you needed to have two different buttons for ASC and DESC, you can override the direction in the link as follows:

<ul class="dropdown-menu pull-right">
    <li>@sortablelink('tag', 'Alphabetically [A-Z]', ['direction'=>'asc'])</li>
    <li>@sortablelink('tag', 'Reverse Alphabetically [Z-A]', ['direction'=>'desc'])</li>
    <li><a href="#">TBD: Most documents</a></li>
    <li><a href="#">TBD: Fewest documents</a></li>
    <li class="divider"></li>
    <li><a href="/tags">Reset (by Time Created)</a></li>
</ul>

@robbielove
Copy link

Fixes #187

@robbielove
Copy link

I tried this out (without using the session part) - I had a different use case - I wanted to override direction to provide a way to start with a page on the default sort column (I have it defined per model) and give it the opposite direction so that it naturally sorted the other way for the default sort field
I found that I required these changes to your PR for it to work in my case
7568d72

We might need to find a way to allow the icon to be changed or remain as the default sort icon - as not everyone using the package will be passing direction for the reason you intend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants