In my app users can save queries. I want to warn them if they are
about to overwrite an existing query (same name). I wanted to do this
with a confirm javascript popup.
My question is: Is it possible to generate a confirmation popup from
an RJS template and then somehow get the answer back? To know if my
controller should overwrite the query or just discard the changes.
Up until now, I didn't find a way to generate a confirmation popup
through RJS, except with the call method to call a javascript method
that will generate this for me...but I was hoping for something a bit
more ruby...and it doesn't solve the problem of getting the answer back
to the controller.
Ah I never even realized that you could pass the options like that.
But unfortunately it doesn't exactly work in my case. The problem is
that the condition is not only server-side, but it depends on what the
user enters as the name of the search:
<%= form_remote_tag(:url => {:action => 'save_query'},
:confirm => 'Are you sure you want to overwrite
this?',
:html => {:id => 'save_query_form'}) %>