Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

model.addChangedListener behavior

$
0
0

@Hesh wrote:

In the following code, the model is changed, plus a model.addChangedListener is being registered to detect any subsequent changes made by user actions.

I want the callback function, myModelChanged to be invoked only on subsequent changes, and not when the whole model is changed. I have tried using a flag newModel = true for the purpose, turning it to false after a new model has been created.

However, the callback method is invoked in both situations, when the new model is created, and when it is changed by user actions.

var newModel = true;

function diagChange(nodes, links) {
  diagram.model = new go.GraphLinksModel(nodes, links);
  newModel = false;
  diagram.model.addChangedListener(function (e) {
      if (!newModel && e.isTransactionFinished) {
        myModelChanged(diagram.model.toJSON());
      }
    }
  );
}

How can I make sure that the callback is called only with the subsequent changes to the model?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles