Return and get object

How to return and get go.Node object with JQuery?

GoJS doesn’t use jQuery to access Nodes. (GoJS doesn’t depend on jQuery at all). Moreover, GoJS Nodes are not DOM elements, they are dynamic renderings on an HTML Canvas element that GoJS controls.

You can get a reference to nodes in multiple ways. To get a reference to the first selected node:

var node = myDiagram.selection.first();

To access an iterator of all nodes in the Diagram:

var itr = myDiagram.nodes; // returns a SetIterator

What are you trying to do?

I try the call this way : myDiagram.nodeTemplate = getSiteNode();

but error :

Uncaught Error: Panel.type value is not an instance of a constant of class Panel: function ( selector, context ) {
		// The jQuery object is actually just the init constructor 'enhanced'
		return new jQuery.fn.init( selector, context, rootjQuery );
	}

Function this way :

function getSiteNode() {
     var node = 
        $(go.Node, "Auto",
            {
                selectionObjectName: "PANEL",
                isTreeExpanded: false,
                isTreeLeaf: true,
            },
            {
                mouseEnter: mouseEnter,
                mouseLeave: mouseLeave
            },
            $(go.Shape, "Rectangle",
                new go.Binding("fill", "statusColor"),
                new go.Binding("stroke", "critical",
                    function(b) { return (b ? "green" : "blue"); })),
            $(go.Panel, "Table",
                new go.Binding("background", "statusColor"),
                { padding: 0.5, name: "TEXT" },
                $(go.RowColumnDefinition, new go.Binding("background", "statusColor"), { column: 0, separatorStroke: "black", coversSeparators: true }),
                $(go.RowColumnDefinition, new go.Binding("background", "color"), { column: 1, separatorStroke: "black", background: "white" }), // 2 bordures apparaissent
                $(go.RowColumnDefinition, new go.Binding("background", "color"), { column: 2, separatorStroke: "black", background: "white" }),
                $(go.RowColumnDefinition, { row: 0, separatorStroke: "black" }),
                $(go.RowColumnDefinition, { row: 1, separatorStroke: "black" }),
                $(go.TextBlock, new go.Binding("text", "text"), new go.Binding("background", "statusColor"), { name: "SHAPE", row: 0, column: 0, rowSpan: 2, margin: 5, textAlign: "center", font: "bold 14px sans-serif" }),
                $(go.TextBlock, "2G\nTDM", { isMultiline: true, row: 0, column: 1, margin: 5, textAlign: "center", font: "5px sans-serif" }),
                $(go.TextBlock, "2G\nIP", { isMultiline: true, row: 1, column: 1, margin: 5, textAlign: "center", font: "5px sans-serif" }),
                $(go.TextBlock, "3G", { isMultiline: true, row: 0, column: 2, margin: 5, textAlign: "center", font: "5px sans-serif" }),
                $(go.TextBlock, "4G", { isMultiline: true, row: 1, column: 2, margin: 5, textAlign: "center", font: "5px sans-serif" }),
                $("TreeExpanderButton", {
                        "ButtonIcon.desiredSize": new go.Size(3, 3),
                        fromSpot: go.Spot.Right,
                        toSpot: go.Spot.Right,
                    } 
                ))
        );
     return node;
}
function mouseEnter(e, obj) {
    var shape = obj.findObject("SHAPE");
    shape.background = "#6DAB80";
    shape.stroke = "#A6E6A1";
    var text = obj.findObject("TEXT");
    text.background = "#6DAB80";
    text.stroke = "white";
}

function mouseLeave(e, obj) {
    var shape = obj.findObject("SHAPE");
    shape.background = obj.data.color;
    shape.stroke = "black";
    var text = obj.findObject("TEXT");
    text.stroke = "black";
}

In our samples we define:

var $ = go.GraphObject.make;  // for conciseness in defining templates

But this conflicts with jQuery if you are using that too.

Either you need to use jQuery’s no conflict mode, or you must change the alias that we define for go.GraphObject.make.

For instance you could use:

var $$ = go.GraphObject.make;  // for conciseness in defining templates

And then use $$ everywhere for GoJS make.

 var node = 
    $$(go.Node, "Auto",

etc.

I am grateful thank you very much for your help