rcarcasses / vue-cytoscape

cytoscape.js now inside vue.js
https://rcarcasses.github.io/vue-cytoscape
MIT License
96 stars 34 forks source link

Way to use cy instance outside of afterCreated? #22

Closed balaram26 closed 5 years ago

balaram26 commented 5 years ago

Hi,

I use 'preconfig' and 'afterCreated' to load the cytoscape graph. Now i need to add cytoscape manipulative functions from vue buttons, but for this i need to use cy element. By default if i use 'this.$cytoscape.instance' ,it doesn't work unless i reload the whole page using refresh button. Is there any way to access cy element outside of the 'afterCreated'? Because 'this.$cytoscape.instance' can't be used after switching page views, it requires me reload whole page again every time.

herosPan commented 5 years ago

I don't think it's a problem with this.$cytoscape.instance. I assign the elements in the config. This problem will not occur, but Duplicate keys detected: '25'. This may cause an update error. Will it be elements? Assignment problem, what should be done

rcarcasses commented 5 years ago

Hi,

Version v1.0.1 now support multiple cytoscape instances, so you should be able to recreate the component as many times as you need. Beware of the breaking changes. On the other hand, since we no longer have a single cytoscape instance, this.$cytoscape.instance has been remove since it no longer makes sense. You should use the cy-element api as much as possible, if you still need to access the cy instance then you should keep using afterCreated lifecycle hook and store a reference if required.

I'll close the issue since I believe is solved in the newest version, anyway feel free to reopen it or create a new one if you still have problems with this.