rails — Add div (popup) to flash[:notice]
-
18-09-2020 - |
Frage
I have a flash[:notice] = "Thanks for signing up!" I would like to add a link that activates this modal popup window I have with javascript.
The code for the popup is
<div>
<a rel="group" class="group" title="Title 1" href="/images/screencap1.jpg" >Find out how to use us</a>
<div style="display: none" >
<a rel="group" class="group" title="Title 2" href="/images/screencap2.jpg" >Thanks for joining! Let's get the ball rolling and explain how our service works works... </a>
</div>
How can I insert the above div into the flash[:notice]?
I tried just adding in between the " " but the double qoutation marks are messing the code up.
Lösung
Instead of using double-quotes, use single quotes to make it a literal.
That is, put the entire div in single quotes (while maintaining the double quotes in the div).
Andere Tipps
Presumably you could just escape the quotes with a backslash, might look a bit nasty.
Maybe you could assign the result of rendering a partial to flash[:notice].
Eg (a guess):
flash[:notice] = render_to_string(:partial => "notice", :layout => false)
and create a partial "_notice.erb.html" in the view directory.