jsplumb 1.4.1 deleteEndpoint by uuid or object example

倖福魔咒の 提交于 2019-12-23 19:04:14

问题


I have some div elements with 2 endpoints for each element (one the left and one the right side). Now I want to delete every right sided endpoint. Everyone of this endpoints has its own unique uuid. I got an array of every uuid of the right sided endpoints -> iterate through them and delete every single one of them but this wont work

can anyone give me an working example of deleting an endpoint by uuid or object ? in my case it wont work with both. I got this errormessage every time:

TypeError: o is undefined jquery.jsPlumb-1.4.1-all.js Line 681

$(elementArray).each(function(){
    //the uuid
    var currentUuid = 'rightEndpoint_'+this;
    //the endpoint object -> that acutually works
    var getCurrentEndpoint = jsPlumb.getEndpoint(currentUuid);
    //delete the endpoint -> here I got the error message
    jsPlumb.deleteEndpoint(currentUuid);
}); 

thanks in advance!


回答1:


var that=$('div');      //get all of your DIV tags having endpoints
for (var i=0;i<that.length;i++) {
        var endpoints = jsPlumb.getEndpoints($(that[i])); //get all endpoints of that DIV
            for (var m=0;m<endpoints.length;m++) {
                if(endpoints[m].anchor.type=="Right") //Endpoint on right side
                      jsPlumb.deleteEndpoint(endpoints[m]);  //remove endpoint
            }
}

By using above code there will be no need to store the Endpoints uuid.



来源:https://stackoverflow.com/questions/17786329/jsplumb-1-4-1-deleteendpoint-by-uuid-or-object-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!