2012-12-31 31 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);