Vote #71652
完了"Submit and continue" is broken
0%
journals
--------------------------------------------------------------------------------
Reproduced with FF & Chrome, works fine on www.redmine.org but not on http://xxx.m.redmine.org.
According to my log, worked fine on r9381.
Since then, looks like submit control name is no more in @POST@ form data.
--------------------------------------------------------------------------------
Guess it's due to r9391 for #6555 wich disables @input[type=submit]@.
--------------------------------------------------------------------------------
Following replacement might be overkill but works on Chrome & IE8:
<pre><code class="javascript">
function addFormObserversForDoubleSubmit() {
$$('form[method=post]').each(function(form) {
form.on('submit', function(form_submission) {
alreadySubmitted = (form.getStorage().get('submitting') == true);
if(alreadySubmitted)
form_submission.stop();
else
form.getStorage().set('submitting', true);
});
});
}
</code></pre>
--------------------------------------------------------------------------------
Shorter, not tested:
<pre><code class="javascript">
function addFormObserversForDoubleSubmit() {
$$('form[method=post]').each(function(form) {
form.on('submit', function(form_submission) {
if(form.getStorage().get('submitted'))
form_submission.stop();
else
form.getStorage().set('submitted', true);
});
});
}
</code></pre>
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Note: of course the above code will break any form in the application which should be allowed to be submitted more than once.
--------------------------------------------------------------------------------
The shorter patch works fine for with FF11, latest Chrome and IE6/9 as well. Please commit.
Etienne Massip wrote:
> Note: of course the above code will break any form in the application which should be allowed to be submitted more than once.
So did r9391. We can add a special class on forms that need to be submitted more than once.
--------------------------------------------------------------------------------
Jean-Philippe Lang wrote:
> So did r9391. We can add a special class on forms that need to be submitted more than once.
Are there such forms? I was thinking of some Rails dark magic reloading only a part of the form DOM via XHR on form submission, but I don't know if it exists?
--------------------------------------------------------------------------------
I don't think there is any of these forms in the core but it might be desirable, just in case a plugin needs it. Something like:
<pre><code class="javascript">
function addFormObserversForDoubleSubmit() {
$$('form[method=post]').each(function(form) {
if (!form.hasClassName('multiple-submit')) {
form.on('submit', function(form_submission) {
if(form.getStorage().get('submitted'))
form_submission.stop();
else
form.getStorage().set('submitted', true);
});
}
});
}
</code></pre>
--------------------------------------------------------------------------------
Think you've got the best answer.
--------------------------------------------------------------------------------
Fix committed, thanks.
--------------------------------------------------------------------------------
related_issues
relates,Closed,6555,Double-click on "Submit" and "Save" buttons should not send two requests to server