Div already has a diagram associated with it


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++) {

1 Like

What is this.diagram? That is very confusingly named.

You need to set Diagram.div, Diagram | GoJS API, to null. In this case I think:

    this.SearchPalette.div = null;