0

在我的应用程序中,我在一个模块中使用 jsPlumb lib,有没有办法找出未连接的端点?

4

1 回答 1

1

由于API Document中没有获取所有端点的函数,因此您需要获取所有具有端点的元素并检查其端点是否有连接:

var elem = $('.havingEndpoint'); // get elements having endpoint based on its class
var emptypoints=[],k=0;          //consists of all empty endpoint objects which can be used to manipulate them
for(var i=0;i<elem.length;i++)   // for all elements having endpoints iterate
{
     var eps=jsPlumb.getEndpoints($(elem[i]));  //get all endpoints of element
     for(var j=0;j<eps.length;j++)
     {
          if(eps[j].connections.length==0)    // check no. of connections
               emptypoints[k++]=eps[j];       //if true add to emptypoints array
     }
 }
 console.log("no. of empty points: "+ k);     
于 2013-11-28T10:35:08.467 回答