I am playing with jsplumb, but I am not able to delete the connection between two divs having only the id of one div.


If you've multiple connections from or to elements, detaching all connections is maybe not the best solution to delete a connection. There is a (not well documented) function to detach exactly one connection:

jsPlumb.detach(connection, {
fireEvent: false, //fire a connection detached event?
forceDetach: false //override any beforeDetach listeners
})

In my example, I want to delete a connection when the connector is clicked:

 jsPlumb.bind('click', function (connection, e) {
jsPlumb.detach(connection);
});

2017年10月01日57分04秒

I found the solution in the documentation (http://jsplumb.org/doc/usage.html)

jsPlumb.detachAllConnections("elementId");

2017年10月01日57分04秒

If source div or target div id is already known, then you can delete the connection like this:

var conn = jsPlumb.getConnections({
//only one of source and target is needed, better if both setted
source: sourceId,
target: targetId
});
if (conn[0]) {
jsPlumb.detach(conn[0]);
}

You can also use jsPlumb.getAllConnections() to get the array of all connections, and test every connection's sourceId or targetId to get exactly the connection you need;

2017年10月01日57分04秒

After all the endpoint connections, to and from the element are deleted, you need to detach it as shown in the 3rd line

jsPlumb.detachAllConnections(divID);
jsPlumb.removeAllEndpoints(divID);
jsPlumb.detach(divID);
divID.remove()

2017年10月01日57分04秒

Hi you can refer to this: Detach connection jsPlumb

This block of code allows to detach connection if a connection was clicked:

jsPlumb.bind("click", function(conn) {
jsPlumb.detach(conn);
});

2017年10月01日57分04秒

This code removes all "wrong" connections in a game I'm developing. I hope it helps

var wrong_connections = new Array(DB_ID, ANOTHER_DB_ID);
var connections = jsPlumb.getConnections();
$.each(connections, function(index, value) { // going through all connections
var source_id = value.source.attr('id').substring(28); // I need the ID from DB so I`m getting it from the source element
for (var a = 0; a < wrong_connections.length; a++) {
if (source_id == wrong_connections[a]) {
jsPlumb.detach(value);
}
}
});

2017年10月01日57分04秒

jsPlumb.deleteConnectionsForElement(elementId)

works. Though it's old I'd like to add that finding out what methods a library has, provided it's self descriptive enough is quite easy.

如何删除jsPlumb连接的更多相关文章

  1. Oracle ORA-01940: 无法删除当前连接的用户

    当我们要删除一个oracle的用户时,如果有其他人连接到数据库则会报以下错误: ORA-01940: 无法删除当前连接的用户 处理办法就是:将连接到当前用户的session给kill掉. 处理步骤如下 ...

  2. ORA-01940: 无法删除当前连接的用户

    删除用户报错 SQL> drop user ODI_SRC CASCADE; drop user ODI_SRC CASCADE * 第 1 行出现错误: ORA: 无法删除当前连接的用户 查看 ...

  3. 解决ORA-29857:表空间中存在域索引和/或次级对象 & ORA-01940:无法删除当前连接的用户问题 分类: oracle sde 2015-07-30 20:13 8人阅读 评论(0) 收藏

    今天ArcGIS的SDE发生了一点小故障,导致系统表丢失,所以需要重建一下SDE数据库,在删除SDE用户和所在的表空间过程中遇到下面两个ORA错误,解决方法如下: 1)删除表空间时报错:ORA-298 ...

  4. ORACLE无法删除当前连接用户

    今天在做Oracle数据库是遇到ORACLE无法删除当前连接用户 ,经查找可用如下方法解决 . 在Oracle中删除用户时提示:ORACLE无法删除当前连接用户  可以用以下语句    Sql代码   ...

  5. 强制删除正在连接的Oracle用户,以删除SDE用户为例

    . 有时候想强制删除一个已经连接的Oracle用户,不能直接删除,可以用Kill会话信息. 比如今天想删除一个被连接的SDE用户,可以用以下方法删除一个“正在被连接”的用户. 1.查看所有用户的会话信 ...

  6. tfs团队项目删除原来连接的默认账户

    1.在用visual studio 连接团队项目时,首次输入用户名和密码后,默认保存住凭据了,等以后连接会自动采用首次的凭证. 但是如何采用新的用户重新登录呢.如图所示,删除原有的凭证.删除后重启电脑 ...

  7. linux 链接的使用 创建和删除符号连接(软、硬链接)

    1 . 使用方式 :ln [option] source_file dist_file   (source_file是待建立链接文件的文件,dist_file是新创建的链接文件)            ...

  8. ora01940 无法删除当前连接的用户

    我用system这个用户登录oracle,想删除掉一个自己创建的用户user,在网上找到的方法都是说先查找到该用户连接的会话select username,sid,serial# from v$ses ...

  9. linux 链接的使用 创建和删除符号连接

    1 . 使用方式 :ln [option] source_file dist_file                     -f 建立时,将同档案名删除.                     ...

随机推荐

  1. Hadoop mapreduce执行过程涉及api

    资源的申请,分配过程略过,从开始执行开始. mapper阶段: 首先调用默认的PathFilter进行文件过滤,确定哪些输入文件是需要的哪些是不需要的,然后调用inputFormat的getSplit ...

  2. CF949D Curfew

    传送门 跟这个大佬学的->戳我 假设只有一个宿管,那么从前往后做的过程中,如果能到达某个寝室范围内的人数不够\(b\),那么不如把这个寝室空出来,这样更有利于后面的抉择;反之,就把这个寝室搞正好 ...

  3. 深入剖析ThreadLocal实现原理以及内存泄漏问题

    关于ThreadLocalMap<ThreadLocal, Object>弱引用问题: 当线程没有结束,但是ThreadLocal已经被回收,则可能导致线程中存在ThreadLocalMa ...

  4. VS Code中Matlab插件安装设置

    Install the extension in VS Code Open the command palette using Ctrl+Shift+P Type ext install Matlab ...

  5. SpringBoot使用外置的Servlet容器

    SpringBoot默认使用嵌入式的Servlet容器,应用打包成可执行的jar包 优点:简单.便携 缺点:默认不支持jsp,优化定制比较复杂(使用定制器serverProperties.自定义Emb ...

  6. Windows和Mac上NodeJS和Express的安装

    一.安装NodeJS,官网上下载,https://nodejs.org/en/ 直接下一步安装就行了. 打开命令行工具,输入 node -v 则会出现node的版本,则成功了. 下面我们介绍如何安装e ...

  7. 反汇编调试内核驱动 Oops提示【转】

    以下部分内容转自:https://blog.csdn.net/jiatingqiang/article/details/7481497 反汇编调试内核驱动 arm-none-linux-gnueabi ...

  8. mysql系列五、mysql中having的用法

    HAVING 子句对 GROUP BY 子句设置条件的方式与 WHERE 和 SELECT 的交互方式类似.WHERE 搜索条件在进行分组操作之前应用:而HAVING 搜索条件在进行分组操作之后应用. ...

  9. Vue.js——component(组件)

    概念: 组件(Component)是自定义元素. 作用: 可以扩展HTML元素,封装可重用的代码. <div id="myView"> <!-- 把学生的数据循环 ...

  10. 通过本地yum源安装软件报错[Errno 14] PYCURL ERROR 56 - "Failure when receiving data from the peer"

    通过本地yum源安装软件报错 http://192.168.3.85/centos/6/os/x86_64/Packages/php-pdo-5.3.3-47.el6.x86_64.rpm: [Err ...