2012-12-31 38 views

回答

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);