jsPlumb - 如果指定了目标或源,如何拒绝连接(分离)?

时间:2015-05-06 09:23:06

标签: jsplumb

我是jsPlumb的新手,我正在使用demos。在指定目标或源时,我不需要允许连接。我的意思是:当目标是X时 - 无法建立连接。

1 个答案:

答案 0 :(得分:1)

jsPlumb在建立连接时触发事件connection

jsPlumb.bind("connection", function(info) {
    if(info.sourceId==='abc'){
      jsPlumb.detach(info.connection);
    }

});

info是具有以下属性的对象:

connection - the new Connection. you can register listeners on this etc.
sourceId - id of the source element in the Connection
targetId - id of the target element in the Connection
source - the source element in the Connection
target - the target element in the Connection
sourceEndpoint - the source Endpoint in the Connection
targetEndpoint - the targetEndpoint in the Connection

参考文献:

http://www.jsplumb.org/doc/events.html#evt-connection-detached http://www.jsplumb.org/doc/removing.html http://www.jsplumb.org/apidocs/classes/jsPlumb.html#method_detach