问题:
I am dynamically building the content of a div using a function . First time it is loading ok but second time it is giving the common error
'div already has a diagram associated with it' . I have tried the solution by setting the div id to null . But it is giving error div is not a function. My code is like this. How to resolve this issue.
this.addSearchPaletteDatas = function (datas) {
this.diagram.div('myPaletteSearch') = null;
this.SearchPalette =
this.diagram(go.Palette, "myPaletteSearch", // must name or refer to the DIV HTML element
{
"animationManager.duration": 800 // slightly longer than default (600ms) animation
});
this.SearchPalette.layout.sorting = go.GridLayout.Forward;
this.SearchPalette.nodeTemplateMap.add("Default", templateDiagram);
this.SearchPalette.nodeTemplateMap.add("Start", templateDiagram);
this.SearchPalette.nodeTemplateMap.add("End", templateDiagram);
for (var i = 0; i < datas.length; i++) {
this.SearchPalette.model.addNodeData(datas[i]);
}
};
解决方法:
You need to set Diagram.div, http://gojs.net/latest/api/symbols/Diagram.html#div5, to null. In this case I think:
this.SearchPalette.div = null;
官方答案:
更多属性设置及说明:http://gojs.net/latest/api/symbols/Diagram.html