Hu Shau Chiang
Hu Shau Chiang

Reputation: 75

Submit the form after submit ( Ruby on Rails )

I am a newbie on Ruby on Rails

I have a regular form in a "new" page. I hope when the user fulfilled the form and submit this form. The page can popup a bootstrap modal and display the full content the user just typed in the form.(like a confirm page)

How can I do this?


I found this http://archive.railsforum.com/viewtopic.php?id=11255 seems it can help me solve my problem but can I change <div id="preview"> to a bootstrap modal(or other popup)?

Upvotes: 0

Views: 319

Answers (1)

Danny Y
Danny Y

Reputation: 261

You can use JavaScript to show the modal based on an onclick or onsubmit event

<%= submit_tag, :onclick => "launchConfirmPage();" %>

where launchConfirmPage() is some JS function that shows the modal filled with info. Then in that modal, have the actual submit button for the form. I'm not entirely sure of the specifics of how a submit_tag works, but you can also try using an anchor tag or button_tag to achieve the same thing if that doesn't work.

Upvotes: 1

Related Questions