gpt4 book ai didi

javascript - 从 div 中删除所有 jsPlumb 端点

转载 作者:行者123 更新时间:2023-11-30 16:53:05 25 4
gpt4 key购买 nike

我正在尝试从 div 中删除所有 jsPlumb 端点,源端点在右侧,目标在左侧。

enter image description here

这是将端点添加到 div 的代码:

addEndpointsToDiv("exp1", ["Right"], ["Left"])

function addEndpointsToDiv(divId, sourceAnchors, targetAnchors) {
for (var i = 0; i < sourceAnchors.length; i++)
{
var sourceUUID = divId + sourceAnchors[i];
instance.addEndpoint(divId, sourceEndpoint,
{
anchor: sourceAnchors[i], uuid: sourceUUID
});
}
for (var j = 0; j < targetAnchors.length; j++)
{
var targetUUID = divId + targetAnchors[j];
instance.addEndpoint(divId, targetEndpoint, { anchor: targetAnchors[j], uuid: targetUUID });
}
};

问题:如何从一个 div 中删除所有这些端点?

以下是我的一些失败尝试:

尝试 #1:

instance.deleteEndpoint(divId)

尝试 #2

var endpoint = instance.getEndpoint(divId)
while (endpoint != null)
{
instance.deleteEndpoint(divId)
endpoint = instance.getEndpoint(divId)
}

尝试 #3

var endPoints = instance.selectEndpoints(divId)
endPoints.each(function (endpoint) {
instance.deleteEndpoint(endPoint)
});

尝试 #4

var endpoints = instance.getendpoints(divid)
for (endpoint in endpoints)
instance.deleteendpoint(endpoint.endpoint)

最佳答案

我在这篇文章中找到了答案:https://groups.google.com/forum/#!topic/jsplumb/Hsf6oKQiBt4

我只需要这一行代码:

instance.removeAllEndpoints(divId)

关于javascript - 从 div 中删除所有 jsPlumb 端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30196039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com