I’m using live_link/2
to generate the URL, but I want to use an HTML button to be rendered inside, or give a class name to the a
tag. In the phoenix, link/2
works great, but I’m not sure if the live_link/2
should replicate the link/2
behaviour.
link/2
live_link/2
Does this make sense ? Should be a new feature on LiveView ?
1 Like
mindok
November 4, 2019, 11:13pm
2
You can supply a css class to the live_link function to style the link as a button.
Something like this (using bootstrap buttons):
<%= live_link "Button Text", class: "btn btn-primary",
to: Routes.live_path(@socket, DemoWeb.UserLive.Index, page: @page - 1) %>
and if you want content in the button (e.g. a fancy icon) you can do this:
<%= live_link class: "btn btn-primary",
to: Routes.live_path(@socket, DemoWeb.UserLive.Index, page: @page - 1) do %>
<span class="icon"><i class="fas fa-edit"></i></span>
<% end %>
(Hopefully I won’t get any red-ink from @chrismccord this time )
1 Like
I feel embarrassed, I thought I was using the last version of LiveView, but I was still pointing to the GitHub link. Yap, that works fine. Thanks.
1 Like