Utilizing vue-resource, I successfully retrieve data from my API and incorporate it into my HTML. However, I am encountering an issue where I want to execute a jQuery function after the v-for loop has completed in order for jQuery to recognize elements in my DOM. Here is the snippet of my code:
Javascript
dataUrl = "http://localhost:8081/hesabiha/userSubmissions";
var app = new Vue({
el: "#campaign",
methods: {
getSubmissions: function(){
this.$http.get(dataUrl, function(submissions){
this.$set('submissions', submissions);
});
},
},
ready: function(){
this.getSubmissions();
}
});
HTML
<div v-for="item in submissions" class="grid-item">
<img v-bind:src="item.field_image[0].url" alt="Hello">
</div>
I am attempting to trigger this function on my page:
$('.grid').masonry({
// options...
itemSelector: '.grid-item',
columnWidth: 200
});
Unfortunately, it seems that the function is not working as intended. Is there a way to ensure that this jQuery function runs only after the v-for loop has completed?