Skip to content

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

@dmcbrn

Description

@dmcbrn

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions