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
Core: wait for pendingRequests to finish before submitting form #2369
Core: wait for pendingRequests to finish before submitting form #2369
Conversation
I worked around this using: submitHandler: function (form) {
// CodeMirror saves when form submit events are fired. We need to manually trigger a save
// so that jquery-validation has the correct form data.
$(form).find('.CodeMirror').each(function(i, el){
el.CodeMirror.save();
});
// more stuff here
}, That said, I believe there is still merit to this PR as |
@staabm what's necessary to see this merged and released? |
The PR implies a synchronous remote validation step, right? |
The remote validation is still asynchronous. |
yeah.. I was more about that the newly added condition will check directly after |
I don't see a race condition. Eventually the pending remote validation requests will be 0, unless the input values repeatedly change then it would loop endlessly. |
thx! |
@staabm would you mind publishing
|
@staabm ? |
I will have a look this afternoon.. |
didn't find the time - sorry about that. @bytestream are you willing to help, if I grant you permission todo it yourself? |
@staabm sure, username is bytestream on npm too |
just invted you on npm @bytestream please see the necessary steps at jquery-validation/build/release.js Lines 1 to 22 in eb88df0
|
I just added you to the github repo |
JS Fiddle
https://jsfiddle.net/bytestream/a16ehn0L/18/
Description
When jquery-validation is used with a WYSIWYG editor there can be a delay in synchronisation between the
div[contenteditable]
and the underlayingtextarea
. This delay combined with remote validation leads to a state where the form is valid but does not submit.The issue is hopefully fairly obvious when looking at
stopRequest
:this.form()
can cause new remote validation rules to fire. In the vast majority of cases, the input data is the same and so jquery-validation looks at the cached result and doesn't bother with another AJAX request. In this case however, the delay in synchronisation causes the request data to change so jquery-validation fires another AJAX request. The line noted above currently does not wait for any new remote validation checks to return before submitting the form.Thank you!
@staabm does this make sense?