I have an iframe (id=“salesforce_iframe”) which further contains an div (id=“div_gojs_chart_depedency_map”). Now i want to create gojs diagram on "divmydiagram "
To access a div inside iframe I have to use this code
var iframe = document.getElementById("salesforce_iframe");
var element_diagram = $(iframe.contentWindow.document.querySelectorAll("#div_gojs_chart_depedency_map"))
GOJS documentation tell that you need to pass id to create a diagram I just cannot pass id because it is inside an iframe and throws me an error = “Error handling response: Error: Invalid DIV id; could not get the element with id: div_gojs_chart_depedency_map”
How do I pass this element variable element_diagram instead of div “div_gojs_chart_depedency_map” or is there any other way
Pass the reference to the HTMLDivElement directly, not its id.
You can pass it either as the second argument to go.GraphObject.make, or as the value when setting the Diagram.div property.
Can you please give me an example? If this is my code , what and where i have to change
var iframe = document.getElementById("salesforce_iframe");
var element_diagram = $(iframe.contentWindow.document.querySelectorAll("#div_gojs_chart_depedency_map"))
var diagram = $(go.Diagram, "div_gojs_chart_depedency_map", // id of DIV
{
// Automatically lay out the diagram as a tree;
// separate trees are arranged vertically above each other.
layout: $(go.TreeLayout, {
nodeSpacing: 25,
angle: 0,
layerSpacing: 250,
layerStyle: go.TreeLayout.LayerUniform
}),
initialContentAlignment: go.Spot.Left,
initialAutoScale: go.Diagram.LayerUniform,
isReadOnly: false, // do not allow users to modify or select in this view
allowSelect: true,
allowZoom: true,
scale: 0.60,
hoverDelay: 200,
allowDrop: true,
"undoManager.isEnabled": true,
"animationManager.duration": 800,
"draggingTool.isGridSnapEnabled": true,
});
I tried passing HTMLDivElement object while creating diagram but it gives me an error Error handling response: Error: Trying to set undefined property “align” on object: Diagram ""