Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

GoJS `diagram.model.toJson()` is not not updating after change

$
0
0

I am using SvelteKit and GoJS

I've declared let diagram; before onMount(), and defined diagram = new go.Diagram('Diagram'); inside onMount()and all other details after that, including:

diagram.addModelChangedListener((e) => {            if (e.isTransactionFinished) {                saveDiagramToLocalStorage();             }});

saveDiagramToLocalStorage(); is defined after onMount():

const saveDiagramToLocalStorage = () => {        const modelAsJson = diagram.model.toJson();        console.log('SaveDiagram', modelAsJson);    // no changes on current data        localStorage.setItem('myDiagramModel', modelAsJson);};

And its all working fine, the function saveDiagramToLocalStorage() is beeing called, but,

The issue is:

diagram.model.toJson(); is always returning the same data, in other words is not being updated after changes in diagram.

Except:

Adding new node or link. The new ones are added, but the existing ones are still not updated. (I'm calling diagram.selection.<some_data> and that's well updated, but the diagram.model.toJson() is not picking changes on the existing ones for some reason)

I've tried:

  • putting Diagram.rebuildParts() before diagram.model.toJson();
  • putting saveDiagramToLocalStorage() inside onMount

Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>