admin管理员组文章数量:1416404
My requirement is like, I am adding two endpoints using jsplumb.addEndPoint for two containers named 'container0' and 'container1'.
Now I need to link the two end points using a connector programmatically but the jsplumb.connect creates a new endpoint and connecting and is not using the end point which I have created using jsplumb.addEndpoint .
How could I connect these two end points? Also I just want to add a connection if the connection is not already there for the end points?
My requirement is like, I am adding two endpoints using jsplumb.addEndPoint for two containers named 'container0' and 'container1'.
Now I need to link the two end points using a connector programmatically but the jsplumb.connect creates a new endpoint and connecting and is not using the end point which I have created using jsplumb.addEndpoint .
How could I connect these two end points? Also I just want to add a connection if the connection is not already there for the end points?
Share Improve this question edited Nov 16, 2019 at 4:09 Cœur 38.8k25 gold badges206 silver badges278 bronze badges asked Dec 16, 2013 at 8:10 user1994513user1994513 291 silver badge5 bronze badges2 Answers
Reset to default 6To connect using already existing endpoints you can make use of the Uuid's of the endpoints:
jsPlumb.ready(function () {
var e0 = jsPlumb.addEndpoint("container0",{uuid:"ep1"}), //set your own uuid for endpoint for later access.
e1 = jsPlumb.addEndpoint("container1",{uuid:"ep2"});
jsPlumb.connect({ uuids:[e1.getUuid(),e2.getUudi()] }); // (or) jsPlumb.connect({ uuids:["ep1","ep2"] });
});
According to the API jsPlumb.connect()
can receive
array of UUIDs of the two Endpoints
but it's not the only way to connect endpoints as there's also another way (which is more mon as it's used to connect two objects) with source and target parameters who can receive String or Object (as a DOM object) or directly an Endpoint (which is not the same as a DOM selector of an endpoint, for instance it can be let firstEndpoint = jsPlumb.addEndpoint()
).
So if, like me, you don't want to use universally unique identifier you can stick to classical source target and give endpoint as parameters.
jsPlumb.connect({ source: firstEndpoint, target: jsPlumb.selectEndpoints() });
本文标签: javascriptJsplumb add connection programmatically using endpointsStack Overflow
版权声明:本文标题:javascript - Jsplumb add connection programmatically using endpoints - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744754307a2623367.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论