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

jsPlumb - how to deny connection (detach) if target or source is specify?

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

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