Trigger won't work

Currently i’m building a workflow using templateMap added 3 templates. After i built the workflow and then i use AJAX call to our server to save that JSON file, i saved the JSON content using ‘diagram.model.toJson()’. And load by AJAX call as well and loading by diagram.model = go.Model.fromJson(data);

the funny thing is, the ‘linkDrawn’ and ‘ChangedSelection’ parts which i defined in the diagram both work. But in the diagram.model i defined ‘Changed’ which won’t be triggered any more. Any one have solution to this circumstance?

Many thanks in advance!

Best,
Jeremy

When one creates a new Model, it will have no Changed listeners. That includes the model created by Model.fromJson, because JSON does not support serializing functions.

So you either need to make sure you re-establish the Changed listener on each new model, or you can define the listener as a ModelChanged listener on your Diagram. See the example in the documentation: http://gojs.net/latest/api/symbols/Diagram.html#addModelChangedListener.