Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Newline in confirmation box

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

like image 452
marimaf Avatar asked Jun 16 '11 23:06

marimaf


2 Answers

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" %>
like image 163
James Avatar answered Oct 18 '22 20:10

James


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 ;)

like image 36
Galuga Avatar answered Oct 18 '22 21:10

Galuga