Rails: using link_to to make a link without href

后端 未结 8 1841
情书的邮戳
情书的邮戳 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条回答
  •  萌比男神i
    2020-12-29 19:34

    An alternative is

    = link_to("My hyperlink", "#")
    

    This will give you a link that when clicked, does not reload the page like passing in nil. At the same time, it will set the mouse to pointer on mouseover, which you will not get with the content_tag approach.

提交回复
热议问题