我有一些div元素,每个元素有2个端点(一个是左边,一个是右边)。 现在我想删除每个右侧端点。 这个端点的每个人都有自己独特的uuid。 我得到了一个右侧端点的每个uuid数组 - >迭代它们并删除它们中的每一个但这不会起作用
有人能给我一个用uuid或object删除端点的工作示例吗? 在我的情况下它不会同时使用。我每次都收到此错误消息:
TypeError:o未定义 jquery.jsPlumb-1.4.1-all.js 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);
});
提前感谢!
答案 0 :(得分: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
}
}
通过使用上面的代码,不需要存储端点uuid。