angular-validation-schema
angular-validation-schema copied to clipboard
Its not working with ng-include and directive with template
Its not working with ng-include and directive with template
@sajithmx Would you check for this?
what I have to check ?
Wrong person sorry @sajithmx
any updates on my issue ?
Have you success on using only angular-validation
?
@sajithmx did you ever resolve this?
@huei90 I had angular-validation
working fine, the schema stuff definitely doesn't work from within an include, any ideas
Further investigation...
The querySelectorAll
on line 125 isnt detecting the elements on the DOM as the include hasn't finished loading at that point.
Trying to find a fix
ok so I've tried adding a delay, by either $includeContentLoaded
or just a hacky simple setTimeout
, and it then picks up the form elements from querySelectorAll
, and even applies the correct parameters when I inspect element, but it doesn't actually work
I dont really know enough about the inner workings of angular-validation
and why this would be the case, as it looks like the delay on adding the schema is causing its own problems, so @huei90 if you could give me some input that would help greatly :)
I'm sorry that I didn't have time look into this. I'm calling @thetutlage . 😄
@thetutlage @huei90 any ideas guys? if you aren't able to support let me know and I will make other arrangements, however this is ideal for my use case and would love to utilise it :)
@poppahorse I would suggest you try fixing angular-validation-schema and make it works with angular-validation.
I believe you already know what schema is and it benefits our code 😄
@huei90 I would love to fix it but a) I need it for something fairly time sensitive, and b) as mentioned above I'm not sure on the reasoning why delaying adding the parameters even to angular-validation
would prevent the validation from happening.
I managed to get querySelectorAll
to detect the fields within the include, however at that point, even though inspect shows the params in place correctly (via schema), the validation just doesn't trigger.
I am happy to try and fix it, but going to need pointing in the right direction as to why the validation doesn't occur after a delay. If I made a plnkr would you be able to have a look? :smiley:
sure, you can paste the link and everyone can check it 🍻
Right so here is a demo with the vanilla angular-validation-schema.js
https://plnkr.co/edit/NLRGdUlrLvX9hpEfJiRn?p=preview
If you look in the console, I have got it to output the detected input fields for both forms. The first form doesn't detect any (as the include hasn't loaded yet), while the second one detects them fine.
Next is a version with a modified angular-validation-schema.js
that will delay the querySelectorAll
. Its just a dirty setTimeout
(line 124) at the moment, but behaviour is the same if I use $includeContentLoaded
to detect completion of the include.
https://plnkr.co/edit/acHclPuZaTEdYLnHxQFf?p=preview
In the console, its detecting all the correct inputs opn both forms, but now neither forms work (with or without include), because I suspect the delay is breaking something.
@huei90 this is where I could do with your assistance, as unsure why or how the delay is breaking something, but it seems that is the only way to get it working nicely with includes. Any help you can offer would be greatly appreciated :+1:
@huei90 I'm having the same issues and looking at @poppahorse plnkr examples it's a bit of a mystery why the delay would cause the validation to stop firing. Looks like will need your input to help us progress. Thanks in advance :)
hmmm.. interesting, I'm not sure but it is possible because angular-validation uses $timeout
too 😵
@huei90 ok cool, so are you saying the delay for angular-validation
needs lengthening to wait for the includes also?
Or that the delay for angular-validation-schema
needs to be > the includes but < whatever the $timeout you mentioned above does? :stuck_out_tongue:
@huei90 are we supposed to just set a $timeout
so validation waits until the includes have loaded? Is there not a better way to detect that the includes have loaded before running validation? It feels super hacky just using $timeout
.
@huei90 @thetutlage any ideas? :)
It feels super hacky just using $timeout.
I think so, we need a more solid solution on this.
@poppahorse I have no idea about it, and looks like @thetutlage is busy on something else.