Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding double-submit issues in change_form with a bit of JS #147

Merged
merged 2 commits into from
Sep 17, 2013

Conversation

adamJLev
Copy link
Contributor

This makes the save form not submit twice, and disables the save buttons for a visual cue.

@darklow
Copy link
Owner

darklow commented Sep 11, 2013

What if user hits ESC key while submit page is loading and stops request.
How can he resubmit the page with data he just entered?

  1. I think this feature must be configurable.
  2. Also it would be nice to control this feature per form/model. Therefore it would be better to add some special class for submit button like .btn-debounce and first do checking if form was submitted with button with such class. This would allow to add this feature just for few forms, where double submit is really bad thing.

@adamJLev
Copy link
Contributor Author

I hear you. But even if the user hits ESC or "Stop" in the browser, the request went out and chances are that the object will be created/saved to the db. Stopping the request won't necessarily cancel the transaction.
So when they submit again, either it will save another item (dupe object), or get a duplicate key error, or maybe even do the "really bad thing" again.

I'd say that submitting a db form twice can never be a good thing, but maybe I'm missing something. Do you have an example?

I can definitely add a config param for this, but I believe it should be on by default :)

…rm relies on the button field value for logic
@adamJLev
Copy link
Contributor Author

Just updated my fork slightly, the disabled html attribute was causing some logic to not work properly. that's fixed now.

@darklow darklow merged commit 903f6b7 into darklow:develop Sep 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants