Skip to content
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

input.is-danger is not available right after running $setLaravelValidationErrorsFromResponse() #12

Open
dmcbrn opened this issue Jun 9, 2021 · 0 comments

Comments

@dmcbrn
Copy link

dmcbrn commented Jun 9, 2021

So in my code on axios...catch() I run:

this.$setLaravelValidationErrorsFromResponse({errors: error.response.data});

then I try to find the first element with error:

let firstInputWithErrors = document.querySelector('input.is-danger');

I do this because my inputs are in tabs and I want to open first tab in which validation failed.

However firstInputWithErrors is null unless i put it in a setTimeout() wrapper.

So to fix it I have:

setTimeout(() => {
    let firstInputWithErrors = document.querySelector('input.is-danger');
    //..do rest of my logic
 }, 100);

Is there a nicer way to handle this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant