Javascript jsplumb deleteEndpoint未按预期工作
我对jsPlumb的deleteEndpoint函数有问题 我想删除没有任何连接的端点。我希望在“连接”时触发此操作,但我认为可能存在一些问题 但是我把代码移到了“dblclick”,我发现了同样的问题。标记为删除的一个节点被删除,但随后系统中的每个端点都被冻结在原地——一旦其元素被拖动,就与该元素断开连接。我不确定是什么原因造成的:以下是相关代码和一些屏幕截图Javascript jsplumb deleteEndpoint未按预期工作,javascript,jquery,jsplumb,Javascript,Jquery,Jsplumb,我对jsPlumb的deleteEndpoint函数有问题 我想删除没有任何连接的端点。我希望在“连接”时触发此操作,但我认为可能存在一些问题 但是我把代码移到了“dblclick”,我发现了同样的问题。标记为删除的一个节点被删除,但随后系统中的每个端点都被冻结在原地——一旦其元素被拖动,就与该元素断开连接。我不确定是什么原因造成的:以下是相关代码和一些屏幕截图 jsPlumb.bind("dblclick", function(c) { alert('startin
jsPlumb.bind("dblclick", function(c) {
alert('starting...');
var endpoints_to_delete = new Array();
jsPlumb.selectEndpoints({source:c.sourceId}).each(function(endpoint) {
if( endpoint.connections.length <= 0 )
endpoints_to_delete.push(endpoint);
});
jsPlumb.selectEndpoints({source:c.targetId}).each(function(endpoint) {
if( endpoint.connections.length <= 0 )
endpoints_to_delete.push(endpoint);
});
alert(endpoints_to_delete.length); // 3
$.each(endpoints_to_delete, function(endpoint) {
jsPlumb.deleteEndpoint(endpoint);
});
});
jsPlumb.bind(“dblclick”,函数(c){
警报('开始…');
var endpoints_to_delete=新数组();
selectEndpoints({source:c.sourceId})。每个(函数(端点){
如果(endpoint.connections.length单独循环遍历每个元素并删除端点对我有效-我认为当我从第一个元素.Hn开始使用端点时,对第二个元素上端点的引用受到了破坏
deleteEmptyEndpoints: function(element)
{
var endpoints_to_delete = [];
jsPlumb.selectEndpoints({source:element}).each(function(endpoint) {
console.log(endpoint);
if( !!endpoint && endpoint.connections.length <= 0 )
{
console.log('marking ' + endpoint.getId() + ' for deletion');
endpoints_to_delete.push(endpoint);
}
});
$.each(endpoints_to_delete, function(index, endpoint) {
console.log('deleting endpoint: ' + endpoint);
jsPlumb.deleteEndpoint(endpoint);
console.log('endpoint deleted');
});
}
deleteEmptyEndpoints:函数(元素)
{
var端点_到_delete=[];
selectEndpoints({source:element}).each(函数(端点){
日志(端点);
if(!!endpoint&&endpoint.connections.length)