Javascript 文件保存/加载后Mxgraph overlay事件侦听器已断开

Javascript 文件保存/加载后Mxgraph overlay事件侦听器已断开,javascript,events,mxgraph,Javascript,Events,Mxgraph,我的mxgraph项目中有以下代码: 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); //

我的mxgraph项目中有以下代码:

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);
});
这很好,但是当我保存文件然后加载它时,我得到了错误

Uncaught TypeError: Cannot read property 'apply' of undefined
    at mxCellOverlay.mxEventSource.fireEvent (mxEventSource.js:185)
    at SVGGElement.<anonymous> (mxCellRenderer.js:601)
未捕获类型错误:无法读取未定义的属性“apply”
在mxCellOverlay.mxEventSource.fireEvent上(mxEventSource.js:185)
在SVGGElement。(mxCellRenderer.js:601)

单击覆盖图标时。检查覆盖显示侦听器仍然处于连接状态。我想不出是什么改变了这一点。

你能展示一下你用来保存和加载文件的代码吗?可能有什么东西破坏了那里的引用…它相当长,但唯一引用覆盖的部分只是检查
单元格。注意
是否存在,如果存在,则添加覆盖。我假设您正在保存为XML。。。很难回答。。。在我看来,最有可能发生错误的地方是当您保存并恢复图形时。。。但是如果没有看到代码,就不可能知道。。。