-
Notifications
You must be signed in to change notification settings - Fork 209
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
issue with paginate url params #70
Comments
@hoangvn2404 I need to implement this. Could you pls explain how you managed this or raise a PR? |
@hoangvn2404 Having the exact same issue. Looking at the docs, it looks like the only way to pass params to |
@msmontader I solved it by putting all the filters in an hash "filters" from html and then: in candidate_controller.ex:
and then in index.html.eex:
this retains the filters in the pagination links. Hope it helps. |
@goravbhootra @msmontader Hi guys, sorry for late reply, First I made a little helper that will be used in html view Then I define that as below
with a little help from the module PARAMS
|
Sorry I missed this for such a long time. Did you try passing in the I'm not sure if we would want to take the query params from the |
@mgwidmann I'm passing As an alternative to @hoangvn2404's workaround here is mine: defmodule MyAppWeb.FooView do
use MyAppWeb, :view
import Scrivener.HTML
@distance 2
def pagination_params(params) do
params
|> Map.delete("page")
|> Map.put("distance", @distance)
|> map_to_keyword_list()
end
defp map_to_keyword_list(map) when is_map(map),
do: Enum.map(map, fn {k, v} -> {String.to_atom(k), map_to_keyword_list(v)} end)
defp map_to_keyword_list(value), do: value
end Then in <%= pagination_links @conn, @companies, pagination_params(@conn.params) %> This also felt like a cleaner way to pass my default options (e.g., |
I think we should ideally replicate the query params in the links when we generate the link. We execute the path function in these areas: https://github.com/mgwidmann/scrivener_html/blob/master/lib/scrivener/html.ex#L326 But the If anyone has time for a PR I'd appreciate the help. |
I run into issue that by default the generated pagination do not included any params I used on the search, so basically click on next link will return wrong results.
I know that we have options to pass additional params into the pagination_links but that would be much work if we have to manually do that.
Did I miss something on the docs? or do you intentionally do that? I'm not sure this is an issue or not?
I have done a little work on my project to make it automatically pass all the params into the url, if you need it I can make an PR for this
The text was updated successfully, but these errors were encountered: