Rails: using link_to to make a link without href

后端 未结 8 1869
情书的邮戳
情书的邮戳 2020-12-29 19:05

How can I use the link_to helper to make a link without an href attribute? I want to make a link exclusively for a javascript action, I don\'t want

8条回答
  •  感动是毒
    2020-12-29 19:25

    I prefer using plain HTML without href attribute at all in such cases:

    Open dialog
    

    IMHO it is more readable than content_tag("a","link text").

    • The disadvantage of href=# is that the browser will scroll to the top when clicked by default
    • javascript:; looks ugly

提交回复
热议问题