Add query params to url from a Button click in Phoenix LiveView

In Pragmatic Studio LiveView course they demonstrate how you can add query params to the path using a link.

href={~p"/servers?id=#{server.id}"}

How can you accomplish this using a <button> Can you use phx-click

I want to click on left or right <- -> arrow button to increment or decrement query params recipes/?slide=7

Similar to this url: reference site

Generally if you want a button to act as a link you should still use an <a href tag and just style it to look like a button. This will work best from an accessibility standpoint as well.

3 Likes