简体   繁体   English

向闪存添加远程链接

[英]Adding a remote link to the flash

Hi so I'm working on a project and I want to be able to have a link in the flash that opens in a modal, so I need the link to be remote. 嗨,我正在做一个项目,我希望能够在Flash中有一个以模式打开的链接,因此我需要将该链接设置为远程。 So I have 所以我有

flash[:link] = { text: "Click here",
                 location: new_post_path,
                 remote: true 
               }

but when the flash is loaded, it doesn't actually load as a remote link? 但是当加载Flash时,它实际上不是作为远程链接加载吗?

Any help fixing this would be greatly appreciated. 解决此问题的任何帮助将不胜感激。

Try this: 尝试这个:

flash[:link] = "#{view_context.link_to('Click here',new_post_path, remote: true)}".html_safe

You should render you flash message in view as follows: 您应该在视图中呈现Flash消息,如下所示:

<% flash.each do |_, value| %>
    <%= content_tag :div, value %>
<% end %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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