Error when part added into diagram with category


I try to add new part into a diagram via javascript.

var part= $(go.Node, “Auto”,
$(go.TextBlock,{text:“abc”,editable:false,font:“30pt Arial”})
part.category = “template2”; //error here

Could anyone help? THX!

That could be made to work, but it is far more common to add data directly to the model by calling Model.addNodeData. Please read GoJS Using Models -- Northwoods Software and GoJS Data Binding -- Northwoods Software.

Thank you Walter,
I don’t want to add part into node data. It’s just for measure distance run time.

I think the mismatch of expectations is that one only uses templates if creating parts from data in a model.

So if you create a Node and call Diagram.add on it, that’s what you have – you cannot then depend on the templating system to change the node to be something else.