Hello, I have a table with checkboxes. How do you persist state?
But You could pass the state back to the controller with url, and retrieve it in the params of LV handle_params.
I have used the approach suggested by @kokolegorille and it works just fine. Encode the query (the checkboxes in your case) like you would normally do in the
return_to path that you are passing to your modal and in your LV you handle them in
handle_params. If it’s a form, my
phx-change callback is very thin and just uses
push_patch and all the filtering logic happens in
I’m not sure what you mean here by encoding the query? I’m not sure how to pass the checkboxes into the modal (or if that’s even what you mean?)
I added some code here for context. https://gist.github.com/raquel2000/0db740ccf5fe42c687f1c00ca9c2734a
Encoding them as simple query params. Example:
?city=6+1&location=2. You edited the 1st post, but if I remember right you had a modal in there with a
return_to path. By encoding the checkboxes values as query params into the
return_to path, whenever the user closed the modal, it will return to the
return_to path passed, thus your
handle_params will pick up and re-construct the checkboxes state as if the user never left the page in the first place.