Initializing a diagram model data with a go.Palette

I have a Palette which I initialize its model. If I drag and drop a part from the palette to the diagram I get the node added to the diagram’s node data array with the object from the palette model.

var p = $g(go.Palette, “workPalette”,
{
nodeTemplateMap: d.nodeTemplateMap,
model: new go.GraphLinksModel([ // specify the contents of the Palette
{ category:“question”, name:“Questions”,actions:[{type:“action_route”,to:""}],view:null,questions:[]},
])
});

If I add multiple question nodes it seems that they all point to one actions array. So if I modify the action type I can see the other action in the other node change to the same value. I can understand this, but I would think that when I drag and drop the palette’s model data that it would be making a copy before adding it to the diagram’s model.

Model.copyNodeData normally just does a shallow copy, because it cannot know the sharing semantics of your app’s data.

You could set http://gojs.net/latest/api/symbols/Model.html#copiesArrays to true. I cannot tell whether you also want to set http://gojs.net/latest/api/symbols/Model.html#copiesArrayObjects to true.

I set both these properties to true on both the palette and diagram model with no luck. Is there an example of using the copyNodeDataFunction? The documentation on what is exactly being passed into the function does not exist. Thanks.

Sorry, I was using version 1.4. Switched to 1.5 and setting both the diagram model properties took care of the problem. Thanks for the speedy response. Great product. Getting ready to purchase the lifetime license.