I want to have a confirmation popup on a <% f.submit %>
call on a new object form. Is there a way to do this without javascript?
-
2POst your code, post your errors. What have you tried? Do you have any mockups or examples to show us what you want? (I'm trying to help you write a better question since you're new).– cbrulakApr 2, 2013 at 18:39
Add a comment
|
2 Answers
You want <%= f.submit :confirm => 'Your confirm message' %>
. Just FYI, this is just the short hand for the javascript call.
Edit: As stated in other answers, the new way to have a popup confirm is:
<%= f.submit 'Save', data: { confirm: 'Your confirm message' } %>
-
4
-
<%= f.submit :onclick => "return confirm('your message here')" %>
Works. I'm having a very difficult time understand the technology stack of the app I'm working on. Thanks. Apr 2, 2013 at 19:22 -
But where does the button title go? I'm trying this, but it doesn't work:
<%= f.submit "Some title", :confirm => 'Your confirm message' %>
Jan 16, 2014 at 16:54 -
4
-
1The reasons those probably don't work (and
onclick
does) is because you are missing jquery/ujs. Jun 27, 2017 at 21:19
The correct way is to use:
= f.submit "Save", data: { confirm: "Are you sure you want to submit this form?" }