开发者

Newline in confirmation box

开发者 https://www.devze.com 2023-03-13 08:55 出处:网络
I want to have two lines in my alert box Right now I have the following: <%= link_to \'back\', \'history.back()\', :confirm => \'Are you sure? This is my second line\' %>

I want to have two lines in my alert box

Right now I have the following:

<%= link_to 'back', 'history.back()', :confirm => 'Are you sure? This is my second line' %>

I have tried adding '\开发者_运维百科n' but it is not working, it just writes \n between my text. What should I do?

Thank you in advance


I think the single quotes around your confirm text are causing the \n to be interpreted literally. Try this:

<%= link_to 'back', 'history.back()', :confirm => "Are you sure? \n This is my second line" %>


If you want a multi-line confirm/alert statement, you will need to use double quote. Single quote will not convert your new line feed \n

This would work: :confirm => "You are about to \n DELETE all tracking information.\nAre you sure?"

Hope this helps ;)


New line in JavaScript alert box You need to stop rails from escaping the new line in the generated HTML form. Can you try <%= link_to 'back', 'history.back()', :confirm => raw 'Are you sure? \n This is my second line' %>

0

精彩评论

暂无评论...
验证码 换一张
取 消