Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't use jsplumb with second function

I'm getting my instance like this:

jsp  = jsPlumb.getInstance();
jsp.setContainer(_domnodeId);
jsp.ready(function(){

//doing some stuff - connecting boxes with arrows...

    var conn2 = jsp.connect({
                source:     boxSST_IPMRS_COBRAIP.boxId,
                target:     boxCOBRA_IM.boxId
            });
    }

result:

enter image description here

in another function I'm doing the same:

jsp  = jsPlumb.getInstance();
jsp.setContainer(_domnodeId);

    jsp.ready(function(){   
        //var dynamicAnchor = [ [ 0.2,1,0.5 ],  [ 0.2, 1, 0.5 ], "Top", "Bottom" ];
        var common = {
                  anchor:[ "Continuous", { faces:["bottom","right"] }],
            endpoint:   "Blank",
            connector:[ "Bezier", { curviness:50 }, common ],
            overlays:   [
                            ["Arrow", {location:1, width:10, length:10}],
                        ]
            };

        jsp.connect({
            source: boxes.b1.boxId,
            target: boxes.b2.boxId
        }, common);
}

enter image description here

The arrows are all moving to the left,top corner... var jsp is global and I cleared _domnodeId at the beginning of my second function. Any suggestions?

clearing my domnodeID:

function clean(container){
    //remove everything
    $("#" + container)
            .children()
            .not('nav')
            .remove();

    // box id counter
    window.EvmClasses.chartBox.boxId = 0;
}
like image 341
h0ppel Avatar asked Dec 17 '15 08:12

h0ppel


People also ask

Does jsplumb work with jQuery?

Although jsPlumb has no dependency on jQuery, it also supports jQuery selectors as arguments for elements (vanilla jsPlumb because jQuery's selector object is list-like, ie. it has a length property and indexed accessors). So this will also work, if you happen to be using jQuery in your page:

How do I change the ID of an element in jsplumb?

Because of the fact that jsPlumb uses element ids, you need to tell jsPlumb if an element id changes. There are two methods to help you do this: jsPlumb.setId (el, newId) Use this if you want jsPlumb to take care of changing the id in the DOM. It will do so, and then update its references accordingly.

How many instances of jsplumb can I create?

jsPlumb is registered on the browser's window by default, providing one static instance for the whole page to use. You can also instantiate independent instances of jsPlumb, using the getInstance method, for example:

What is a container in jsplumb?

A Container is some element that jsPlumb will use as the parent for all of the artefacts it adds to the UI. You would make this the parent element of the nodes you are connecting, and then the SVG elements jsPlumb adds for Endpoint/Connectors are siblings of your elements.


1 Answers

I cleared _domnodeId at the beginning of my second function

How did you done that? It seems to me that you didn't clear it properly.

Did you read "Removing" section of the manual?

If you have configured a DOM element with jsPlumb in any way you should use jsPlumb to remove the element from the DOM (as opposed to using something like jQuery's remove function, for example).

Please read it thoroughly. You may need either jsPlumb.empty, deleteEveryEndpoint, or reset.

like image 168
user Avatar answered Oct 13 '22 00:10

user