[Vuejs]-How to bind behaviour in new elements in a vuejs repeat block?

2👍

Try using a watch:

data: {
    "onedaytours": null
},
ready: function(){
    this.$watch("onedaytours", function (newValue, oldValue) {
        this.$nextTick(function () {
            $(".flipblock").flip();
        });
    });

    this.fetchOneDayTours();
},

This assumes that .flip() is safe to call on elements multiple times. Otherwise, you’ll either need to do something like mark the elements that have been initialized so you can skip them, remove flip from all elements and then apply to all again, etc.

The $nextTick call is needed to allow the DOM to update (when Vue is using async batch updates).

Leave a comment