Praveen Kamath
Praveen Kamath

Reputation: 1059

Vue JS : Flush / reload the whole tree-view

I am new to Vue JS. Just implemented a sample Tree view.

How do I flush the whole tree-view and reload it with new content entirely?

Went through the Vue API's but failed to find any.

Please help.

Upvotes: 0

Views: 1188

Answers (2)

Praveen Kamath
Praveen Kamath

Reputation: 1059

My modified code snippet:

if(demo!=null) {
    demo.flushtree(tableJson);
} else {
    demo = new Vue({
    data: {
     treeData: tableJson
    },
    methods: {
        flushtree: function(newData) {
        this.treeData = newData;
    }
}
})
demo.$mount('#demo');
}

Thanks :)

Upvotes: 0

Linus Borg
Linus Borg

Reputation: 23988

If you refer to this: http://vuejs.org/examples/tree-view.html

There is no special method nessessary for this. you would simply replace the data with new data:

var demo = new Vue({
  el: '#demo',
  data: {
    treeData: data
  },
  methods: {
    //call this method e.g. from a buttons click event.
    flushtree: function() {
      this.treeData = newData // get new Data from somehwere.
    }
  }
})

Upvotes: 1

Related Questions