vue-jstree icon indicating copy to clipboard operation
vue-jstree copied to clipboard

Updating 'data' props from parent does not seem to call `.initializeData`

Open ccharly opened this issue 6 years ago • 3 comments

Hi,

I was unable to access functions like openChildren closeChildren from my item using the item-click event. It seems that .initializeData is only called in created hook. In my case, I do update data from outside of my component.

It this intended? I tried to used updated instead of created but wasn't able to get it work either..

Thanks for your help!

ccharly avatar May 17 '18 14:05 ccharly

Actually adding a watch statement onto data prop fixes that. But maybe you have a better solution.

ccharly avatar May 17 '18 15:05 ccharly

Can you write example how you fix that?

kentuport avatar Jun 13 '18 10:06 kentuport

hi

It worked by calling the initialize method in the child component each time the data was updated.

watch: {
  data : function() {
    this.$refs.tree.initializeData(this.data);
  }
},

this.$refs.tree 'tree' should match the ref attribute name in the component tag. Although it may not be a fundamental solution, I am pleased if it will be helpful.

Im sorry my English is not good. Thanks.

s4110 avatar Jun 28 '18 03:06 s4110