RubyRedGrapefruit
RubyRedGrapefruit

Reputation: 12214

How can I use link_to to create a "blank" link in Rails 2.3.11?

I just want to create a link that does nothing when it is clicked (other than the jQuery code I am binding to the link's ID.

I am returning "false" in my Javascript function that is bound to the links, but I would just like the link to be "#" or something like that. When I try this:

link_to("Link", "#here")

That gives me the entire current url, plus "#here" stuck on the end.

Upvotes: 0

Views: 2484

Answers (3)

Pritesh Jain
Pritesh Jain

Reputation: 9146

You can try something like this

<%= "Link", "javascript:void(0)" %>

Upvotes: 2

Rodrigo Zurek
Rodrigo Zurek

Reputation: 4575

try this

<%= link_to "TEXT" %>

Upvotes: 3

Zajn
Zajn

Reputation: 4088

Try this: <%= link_to('#', :id => 'link_id', :class => 'some_class') %>

Edit

Sorry, I just now saw that this question pertains to Rails 2.3.11. I looked at the api and it looks like it may still work, but if it doesn't, let me know and I'll remove this answer.

Upvotes: 2

Related Questions