2

I am fiddling with JointJS, which uses the Backbone object model. I try to populate the cells with links and sometimes the links do not appear (after a few refreshes they appear again) with this error (in Chrome JS console) :

Uncaught TypeError: Cannot read property '_listenerId' of undefined joint.js:15417

That never appears with the states (simple rectangles from joint.shapes.basic.Rect).

My code for populating the link array is :

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);
};

And the JSON (converted into a JS object) :

[{"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":""}}]

Do you have any idea of what could be the cause of this ? Is is a bug from Joint.js ?

Thanks ! Adrian

4

1 回答 1

2

我找到了答案:有时链接是在形状之前加载的。

于 2014-04-22T15:29:43.983 回答