I have a standard form in my Rails app.
In certain situations I'd like to display a Javascript confirmation dialog when the Submit button is clicked. The catch is that I need to determine whether or not to display this confirmation on the server side as opposed to doing this in Javascript before the request is submitted to the server.
What is the best solution to this?
Should I use AJAX and change my form_for
tag to a remote_form_for
tag? I will then be able to pick up a format.js
response to display the confirmation dialog in my controller, but it does feel a bit messy.
Or should I just forget trying to do this with Javascript and just display an intermediate confirmation page?