There is a lot going on in our link template, but the issue lies with the context menu all the way at the end. We used the variable gmk instead of the $ as the $ was being used by jquery already. I’m not following along with how I should change the context menu to not show if the string is empty. Additionally I set the data binding with another function on load before depending on which link is in question so the actual data array wouldn’t be of much help with this issue.
the link template is as follows:
myDiagram.linkTemplate =
gmk(go.Link,
// curves the lines linking node together based on to
// and from locations
{ curve: go.Link.Bezier},
gmk(go.Shape,
// colors the link based on data in linkDataArray
new go.Binding("stroke","color"),
new go.Binding("strokeWidth", "thick")),
// label added to force the links away from each other or
// display information requested
gmk(go.TextBlock, {margin: 30, segmentOffset: new go.Point (0, 4)},
new go.Binding("text", "label")),
// new go.Binding(“fromSpot”, “fromSpot”, go.Spot.parse),
// new go.Binding(“toSpot”, “toSpot”, go.Spot.parse),
// adds a from port label
gmk(go.TextBlock, { segmentIndex: 0, segmentFraction: .4, segmentOffset: new go.Point(0, -7)},
new go.Binding (“text”, “fromPort”)),
// adds a from port label
gmk(go.TextBlock, { segmentIndex: 2, segmentFraction: .4, segmentOffset: new go.Point(0, -7)},
new go.Binding (“text”, “toPort”)),
// extra information can be used using these blank bindings
gmk(go.TextBlock, {segmentIndex: 1, segmentFraction: .5, segmentOffset: new go.Point(0, -7),
segmentOrientation: go.Link.OrientUpright}, new go.Binding (“text”, “topText”)),
gmk(go.TextBlock, {segmentIndex: 1, segmentFraction: .5, segmentOffset: new go.Point(0, 2),
segmentOrientation: go.Link.OrientUpright}, new go.Binding (“text”, “bottomText”)),
{
contextMenu: // define a context menu for each node
gmk(go.Adornment, “Vertical”, // that has one button
gmk(“ContextMenuButton”,
gmk(go.TextBlock, new go.Binding (“text”, “contextMenu”))
)
// more ContextMenuButtons would go here
) // end Adornment
}
);