ontehfritz / Gather

A Ruby on Rails web based survey software to create and distribute surveys demo link below
2 stars 2 forks source link

Multiple submits #1

Closed ontehfritz closed 13 years ago

ontehfritz commented 13 years ago

When creating surveys, sections, etc ... a user can click the submit button multiple times creating duplicate items

ontehfritz commented 13 years ago

used a simple fix with jquery: $('form').submit(function(){ $('input[type=submit]', this).attr('disabled', 'disabled'); });

added to the layout template. so it is applied to all submit buttons. Yes, it won't work if javascript is disabled, however the application won't work either, LOL. You need to have javascript enabled.

ontehfritz commented 13 years ago

$('form').submit(function(){ $('input[type=submit]', this).attr('disabled', 'disabled'); });

Has an issue, forms using multiple buttons contain the name of the button in the ":commit" parameter. This is not submitted when using the above javascript. There is not way to tell what operation you want to execute. Some solutions involve setting a hidden value that contains the action you want to perform. I might try this! This issue is officially reopened!!! AHHHH!!!

ontehfritz commented 13 years ago

found a great way to handle double submits, however it still relies on javascript ... but once again what doesn't, it is very simple and built into rails which is great!

<%= f.submit "Create", :disable_with => 'Creating ...' %>