On Nov 18, 2010, at 9:25 AM, Hassan Schroeder wrote:
On Thu, Nov 18, 2010 at 12:58 AM, Norbert Melzer
<[email protected]> wrote:
I have a form, When i click submit button twice,
My form gets submitted twice, and 2 entries are saved.
But I need only 1 entry to be saved.
Hidden field wich unique ID. If the ID is submitted twice, omit the
new
entry
But suppose the user clicks submit, instantly recognizes an error in
the information, hits stop, corrects the error, and clicks submit
again?
If you discard the *second* submission, there is now a discrepancy
between what the user intended and what you've stored. Uh-oh.
Might want to give that a little more thought :-)
Are you trying to trap a "bounce" here -- a double-click because of
machine or user error that is being interpreted as two separate submit
events? You can easily trap those by adding :disable_with =>
'Saving...' to your button tag. Only the first click will be accepted,
and the button will gray out and stop accepting input after that.
Happens at the JavaScript level, so the response will be very nearly
immediate.
Walter
--
You received this message because you are subscribed to the Google Groups "Ruby on
Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.