Answer the question
In order to leave comments, you need to log in
How to make jquery code events hung on elements only after all data on the server side is loaded?
I have jQuery code like this
function init() {
initRelatedGoodsCarousel();
tags();
..........
};
function initRelatedGoodsCarousel() {
$('.owl-related').owlCarousel({
loop:true,
nav:true,
dots:false,
responsiveClass:true,
responsive:{
0:{
items:2
},
600:{
items:4
},
1000:{
items:6,
margin:0,
autoplay:true,
autoplayTimeout:80000,
}
}
});
}
function tags() {
$('#list_tags li').each(function(){
posDiv($(this));
randomSize($(this));
});
$('.wrap_search_tag').hover(function(){
$('#list_tags li').each(function(){
animateDiv($(this));
});
},
function(){
$('#list_tags li').stop();
});
........
}
<script>
import axios from 'axios'
import callApi from '~/libraries/api.js'
export default {
name: 'Tags',
data () {
return {
tags: []
}
},
updated() {
this.$nextTick(function () {
setTimeout(() => {
init();
}, 1000)
})
},
created: function () {
this.$nextTick(function () {
callApi('tags', '', '').then((res) => {
this.tags = res.data.data;
});
})
}
}
</script>
updated()
called the function init()
from the jQuery code, and I loaded the data from the REST API using callApi()
the created
. setTimeout()
slow down the function with the help init()
, but this also did not work every time. Vuex store
, but this also does not work all the time. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question