Closed GoogleCodeExporter closed 8 years ago
I fixed this by modifying the _fnOnCancelRowAdding(event) function to the
following:
//Called when user cancels adding new record in the popup dialog
function _fnOnCancelRowAdding(event) {
//Close the dialog
oAddNewRowForm.dialog('close');
$(oAddNewRowForm).validate().resetForm(); <---- This is the line I added
$(oAddNewRowForm)[0].reset();
$(".error", $(oAddNewRowForm)).html("");
event.stopPropagation();
event.preventDefault();
}
Original comment by dmol...@gmail.com
on 7 Jun 2011 at 7:14
Also, if the user has the error messages displayed in a div with class "error",
it won't be cleared properly if the form is closed after a validation error.
The changes below fix that:
//Called when user cancels adding new record in the popup dialog
function _fnOnCancelRowAdding(event) {
//Close the dialog
oAddNewRowForm.dialog('close');
$(oAddNewRowForm).validate().resetForm(); // Clears the validation errors
$(oAddNewRowForm)[0].reset();
$("div.error span", $(oAddNewRowForm)).html("");
$("div.error", $(oAddNewRowForm)).hide(); // Hides the error div
event.stopPropagation();
event.preventDefault();
}
Original comment by dmol...@gmail.com
on 8 Jun 2011 at 11:20
Hi,
I have not noticed this issue. I all my examples on the site, when error is
shown following code clear the form and error labels:
$(oAddNewRowForm)[0].reset();
$(".error", $(oAddNewRowForm)).html("");
Only potential issue is that when user closes the form (e.g. click on the [x]
button in the upper right corner), form/messages are not cleared (to enable
user to continue with editing if he accidentelly closed the dialog).
However I have added your code because it does nto collide with the current
code. The only change is that I have not included div in the selector because
would not link to put any constraint such as "you must wrap error labels in the
div tags".
Current code is:
//Called when user cancels adding new record in the popup dialog
function _fnOnCancelRowAdding(event) {
//Clear the validation messages and reset form
$(oAddNewRowForm).validate().resetForm(); // Clears the validation errors
$(oAddNewRowForm)[0].reset();
$(".error", $(oAddNewRowForm)).html("");
$(".error", $(oAddNewRowForm)).hide(); // Hides the error element
//Close the dialog
oAddNewRowForm.dialog('close');
event.stopPropagation();
event.preventDefault();
}
Could you please take the latest version and let me know whether it wrks in
your example?
Thanks,
Jovan
Original comment by joc...@gmail.com
on 11 Jun 2011 at 8:33
This works. I have to include the div/span due to implementation details of my
application.
Original comment by dmol...@gmail.com
on 11 Jun 2011 at 11:06
Ok,I'm closing this issue.
Original comment by joc...@gmail.com
on 11 Jun 2011 at 3:24
Just a note regarding this error: $(oAddNewRowForm)[0].reset is not a function
If you happen to have a form reset button with id="reset", this will cause this
issue to occurr also.
Just a note to assist others.
Original comment by obj...@gmail.com
on 13 Oct 2011 at 7:12
Original issue reported on code.google.com by
dmol...@gmail.com
on 7 Jun 2011 at 6:22