Skip to content

Overriding the direction parameter - #188

Open
khamyl wants to merge 5 commits into
Kyslik:masterfrom
khamyl:master
Open

Overriding the direction parameter#188
khamyl wants to merge 5 commits into
Kyslik:masterfrom
khamyl:master

Conversation

@khamyl

@khamyl khamyl commented Jan 21, 2022

Copy link
Copy Markdown

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
Copy Markdown

Fixes #187

@robbielove

Copy link
Copy Markdown

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.

2 participants