我正在摆弄使用Backbone对象模型的JointJS。我尝试使用链接填充单元格,有时链接不会出现(经过几次刷新后再次出现)此错误(在Chrome JS控制台中):
Uncaught TypeError: Cannot read property '_listenerId' of undefined joint.js:15417
从未出现过状态(来自joint.shapes.basic.Rect
的简单矩形)。
我填充链接数组的代码是:
jQuery.fn.addedges = function (data) {
var links = new Array();
$.each(data, function (key, value) {
links.push( new joint.dia.Link({
source: { id: value.u },
target: { id: value.v },
attrs: { '.connection': { stroke: 'white' }, '.marker-target': { fill: 'yellow', d: 'M 10 0 L 0 5 L 10 10 z'} }
}));
});
graph.addCells(links);
};
JSON(转换为JS对象):
[{"u":"ID_25","v":"ID_26","value":{"label":""}},{"u":"ID_25","v":"ID_27","value":{"label":""}},{"u":"ID_27","v":"ID_26","value":{"label":""}},{"u":"ID_29","v":"ID_26","value":{"label":""}},{"u":"ID_29","v":"ID_121","value":{"label":""}},{"u":"ID_223","v":"ID_121","value":{"label":""}}]
你知道这可能是什么原因吗?是Joint.js的错误吗?
谢谢! 阿德里安
答案 0 :(得分:2)
我找到了答案:有时链接是在形状之前加载的。