Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140788

Mxgraph overlay event listener broken after file save / load

$
0
0

I have the following code in my mxgraph project:

var overlay = new mxCellOverlay(
  new mxImage(mxIcons.GREY.FILE_TEXT, 18, 18),
  null, mxConstants.ALIGN_RIGHT, mxConstants.ALIGN_TOP, new mxPoint(8, -8), 'default');

cell.note = overlay;
graph.addCellOverlay(cell, overlay);

// toggle the text box on and off with icon click
overlay.addListener(mxEvent.CLICK, function(sender, evt)
{
    if (overlay.textBox.visible)
        graph.getModel().setVisible(overlay.textBox, false);
    else
        graph.getModel().setVisible(overlay.textBox, true);
});

This works fine, but when I save the file then load it I get the error

Uncaught TypeError: Cannot read property 'apply' of undefined
    at mxCellOverlay.mxEventSource.fireEvent (mxEventSource.js:185)
    at SVGGElement.<anonymous> (mxCellRenderer.js:601)

when clicking on the overlay icon. Inspecting the overlay shows me that the listener is still attached. I can't figure out what has changed to break this.


Viewing all articles
Browse latest Browse all 140788

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>