Rails - How to put a confirmation popup on a f.submit?

前端 未结 2 468
半阙折子戏
半阙折子戏 2020-12-06 09:21

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?

相关标签:
2条回答
  • 2020-12-06 09:26

    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' } %>
    
    0 讨论(0)
  • 2020-12-06 09:32

    The correct way is to use:

    = f.submit "Save", data: { confirm: "Are you sure you want to submit this form?" }
    
    0 讨论(0)
提交回复
热议问题