Hi, I try to develop an application in which a number of users can collaborate on designing a flowchart. I took the code from the example and I added a listerner for changes to the diagram so I can send changes to a server. The code I use (after reading various documents):
myDiagram.addModelChangedListener(function(e) {
if (e.isTransactionFinished) {
setTimeout(function(e){
var json = e.model.toIncrementalJSON(e);
console.log(json);
},1000);
}
});
The timeout function is added so the tiIncrementalJSON is called well after the page is loaded. I get an error: “cannot read property model of undefined”…
Can anybody show me the right way to get changes to the diagram?
Thank you.
NB:
If I delete the timeout, and use the function as depicted in the document on this site, I get an error on pageload:
go.js:12 Uncaught Error: GraphLinksModel.linkKeyProperty must not be an empty string for .toIncrementalJson() to succeed.
at B (go.js:12)
at or.t.Vw (go.js:1839)
at or.t.Vy (go.js:1772)
at or.t.aB (go.js:1772)
at flowdiagram.php:52
at or.t.zt (go.js:1785)
at Ae.Bb (go.js:268)
at Be (go.js:265)
at Ae.t.Wa (go.js:263)
at Q.Wa (go.js:692)
so I added the timeout.