在我的应用中,我在一个模块中使用jsPlumb lib,有没有办法找出未连接的端点?
答案 0 :(得分: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);