GodziLaravel
6 months ago

How to call a function when element is loaded ?

Posted 6 months ago by GodziLaravel

Hello ,

in template :

<span id="container"></span>

 <h6 @click="getCompetenceLogs">load content</h6>

As you can see, when user clicks on h6 element the JS bellow will add content to <span id="container"></span> through makeCompetenceLogs.

I would like to know how to call elementIsLoaded when the operation is done and <span id="container"></span> is loaded with the new data coming from axios.get(api/co ....`

JS:

...
  methods: {

makeCompetenceLogs(data){
// this will add content to `<span id="container"></span>`
};

elementIsLoaded() {
console.log("element is loaded");
}

getCompetenceLogs() {
axios.get(`api/competence-logs/` + this.loginUserId + `?dateFrom=` + this.dayFrom + `&dateTo=` + this.dayTo)
.then(response => {
this.makeCompetenceLogs(response.data.nextDate); });
}
}

Please sign in or create an account to participate in this conversation.