写在最前:推荐jsplumb中文教程:
https://wdd.js.org/jsplumb-chinese-tutorial
在学习过程中,中文教程中有这样一段:
但是,在实际使用中发现连线无法删除,且报错:
jsPlumb: fire failed for event click : TypeError: jsPlumb.detach is not a function
查看demo源代码,发现demo中引用的js文件为 jquery.jsplumb.js
而我的项目中使用的是更新的版本
结论就是使用deleteConnection(conn)
替换掉detach(conn)
jsPlumb.bind('click', function (conn, originalEvent) {
if (window.prompt('确定删除所点击的链接吗? 输入1确定') === '1') {
jsPlumb.deleteConnection(conn)
}
})