I truly hope that I’m not missing something very obvious here, for this would waste some people their time… But I’m facing the following situation:
Simply trying to generate an arrow up, arrow down, that can be click to order an item higher or lower in a list. This is the following code that I’m trying to achieve this: (using following icons)
<td>
<%= link(tag(:i, class: "fa fa-angle-up"), to: "/link/moveup", method: :post) %>
<%= link(tag(:i, class: "fa fa-angle-down"), to: "/link/movedown", method: :post) %>
<%= link "Delete",
to: Routes.link_path(@conn, :delete, link),
method: "delete" %></td>
Which results in the following html code and how it looks like:
When I change the lines of code so that it’s first the Delete link, then an arrow, it doesn’t get generated twice. Am I doing something wrong or could this be a potential bug?
The link function accepts the string contents as the first arg. I actually wouldn’t have expected the above to work, but I need to check the source. Try this:
<%= link to: "/link/moveup", method: :post do %>
<%= tag(:i, class: "fa fa-angle-up") %>
<% end %>
Thank you for responding.
I’ve tried the following code: (as per your suggestion)
<%= link to: "/link/moveup", method: :post do %>
<%= tag(:i, class: "fa fa-angle-up") %>
<% end %>
<%= link to: "/link/movedown", method: :post do %>
<%= tag(:i, class: "fa fa-angle-down") %>
<% end %>
How did you check the generated HTML? Did you use curl or a similar tool or did you use some view of your browser, the later might still be subject of DOM manipulation via scripts.
Check the output without having loaded any scripts, then add java script module by module, then you’ll see which one breaks your site, then debug that module.
Just using a default generated Phoenix project. The only js files that are getting compiled from webpack are socket.js (default) and app.js (default) which imports phoenix_html, does this mean that the “bug” is most likely in the phoenix_html package?