简体   繁体   中英

Rails link_to - disable after click?

Like in topic - is there some option to remove action for

link_to

after click on it?

No, you need to do this through Javascript. When the link is clicked you can set a disabled attribute. On subsequent clicks, you can then check for the attribute and if it is set, you can then use e.preventDefault(); to prevent the link from being following.

See: jQuery disable a link

If you're using something like Twitter Bootstrap, there are some more elegant options, via button loading states.

根据您要尝试执行的操作,您可能可以设置link_to_iflink_to_unless来实现所需的目标。

Take a look of this, a good explation of this guy:

How to disable HTML links

the right way to do it:

a {
    pointer-events: none;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM