Forum: Ruby on Rails link_to_remote :confirm => as JavaScript function (dynamic)

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
A2fedc2aa6918feba4d4323768a4a076?d=identicon&s=25 Jason Crystal (cclear44)
on 2008-10-22 19:17
Hey all,

Normally you can use the :confirm functionality of link_to_remote to
specify the text of a confirmation dialogue.

For example, :confirm => "hello" generate:
<a href="#" onclick="if (confirm('hello')) { new Ajax.Request ...

I'd like to replace "hello" with a JavaScript call (so that the
confirmation dialogue can contain text based on what a user has so far
done on the page.  If I try to pre-emptively close the quote, it ends up
just getting escaped, and the function name is simply displayed:

:confirm => "'+myFunction()"
<a href="#" onclick="if (confirm('\'+myFunction()')) { new Ajax.Request

Any idea how I might accomplish a dynamic confirmation dialogue?

178d39d478db978402f5a900b88e9be4?d=identicon&s=25 mooseman (Guest)
on 2008-11-19 18:33
(Received via mailing list)
Have you tried :before instead of :confirm
   You'll have to do your own confirm dialog but your function can
build the confirm string any way you want

On Oct 22, 11:17 am, Jason Crystal <>
This topic is locked and can not be replied to.