-
Notifications
You must be signed in to change notification settings - Fork 25
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
Rescanning dynamic inputs does not detect that they are new #107
Comments
A repro and PR are both very welcome. |
aspnet-client-validation/src/index.ts Lines 1392 to 1396 in 062c843
I expect this would work: v.remove(form);
v.scan(form); I'm also about done with a PR for #100 that may improve But generally what you observe is expected: for performance reasons we remember validatable element by |
Apologies both and thanks for your fast replies. I have found the issue. It appears that the input elements when recreated were done so in JavaScript and the validation was not added. I've switched this to server side rendering and it works. So in summary, some idiot(*) changed the code to dynamically recreate the controls but not add the validation back. *Possibly, definitely, me. |
I have a form with radio buttons. The buttons have validation on them to ensure one is always selected.
When those buttons are changed / checked, they are dynamically reloaded from the server with new text but the same name / id.
On trying to run validation I hit an error (element.form is null) as the element that is held within aspnet-client-validation no longer has a form attached. The element on the page does though. A longer trace for the error is below.
I tried doing a v.scan(form) as suggested to refresh the lib with the new inputs, but it seems it thinks it already has them as I get lots of 'already tracked' messages such as;
Perhaps I need to remove the fields first, so I tried variations such as;
Followed by another v.scan(), but this fails with the following. I suspect it is because the validators are still there but the elements are not.
Initial error without attempting to scan or remove;
I can work around this by using { watch: true } on the bootstrap. Which is great, but how should I be doing this if I do it manually?
I can create a repro if needed. If it is decided it is an edge case and you'd like me to submit a PR, I can do that. I just need some direction as I'm not sure of the codebase.
Thank you,
Ryan
The text was updated successfully, but these errors were encountered: