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.