WFransen
Phoenix link tag generated twice
Dear Elixir forum,
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?
Thank you in advance,
Marked As Solved
LostKobrakai
tag/2 is a low level function which does only create a “tag”, aka <name {attrs}>. It doesn’t concern itself with the notion of opening/closing tag.
Also Liked
al2o3cr
Can you post the raw HTML that this generates? The DOM inspector can sometimes display odd things as it tries to “fix” broken markup.
LostKobrakai
Can you try content_tag(:i, …)? This to me seems like a browser trying to fix improper html.
NobbZ
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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









