2016-12-11 17 views
0

jsPlumbを使用して2つの列の一致するウィジェットを作成しています。接続プロセスが正しく動作jsPlumbデタッチした接続のエンドポイントを削除する

jsPlumb.makeSource($(element[0]).find('.match-source-anchor')[0], { 
    maxConnections: 1, 
    uniqueEndpoint: true, 
    isSource: true, 
    enabled: true 
}); 

jsPlumb.makeTarget($(element[0]).find('.match-target-anchor')[0], { 
    uniqueEndpoint: true, 
    isTarget: true, 
    maxConnections: 1, 
    enabled: true 
}); 

:私のようなソースとターゲットを作成しました

var container = $element.find('.match-widget .widget-output:not(.edit)'); 

jsPlumb.getInstance({ 
     PaintStyle: { 
      lineWidth: 6, 
      strokeStyle: '#567567', 
      outlineColor: 'black', 
      outlineWidth: 1 
     }, 
     MaxConnections: -1, 
     LogEnabled: true, 
     Anchors: ['Center', 'Center'], 
     DragOptions: { 
      cursor: 'pointer', 
      zIndex: 2000 
     }, 
     Connector: ['Bezier', { 
      curviness: 30 
     }], 
     Endpoints: [ 
      ['Dot', { 
      radius: 11 
      }], 
      ['Dot', { 
      radius: 11 
      }] 
     ], 
     EndpointStyles: [{ 
      fillStyle: '#FF7D19' 
     }, { 
      fillStyle: '#FF7D19' 
     }], 
     Container: container 
}); 

:として

ザ・jsPlumbインスタンスが作成されます。しかし、私は接続を削除する場合、1つの接続を作成した後の問題は、接続のエンドポイントはまだ表示されます。

config "_deleteOnDetach"を追加しようとしましたが、connectionDetach上のエンドポイントも削除しようとしました。どちらの場合も、エンドポイントは削除されますが、同じ要素を接続しようとするとエラーになります。

だから誰でも私の修正方法を教えていただけますか?

デモ:接続を削除するときjsfiddle

答えて

1

は通常、それは、エンドポイントが、通常はそれで削除されます。エンドポイントが一意に設定されている場合、エンドポイントは削除されません。

jsPlumbコードからこれを参照してください:

// if unique endpoint and it's already been created, push it onto the endpoint we create. at the end 
// of a successful connection we'll switch to that endpoint. 
// TODO this is the same code as the programmatic endpoints create on line 1050 ish 
if (def.uniqueEndpoint) { 
    if (!def.endpoint) { 
    def.endpoint = ep; 
    ep._deleteOnDetach = false; 
    ep._doNotDeleteOnDetach = true; 
    } 
    else 
    ep.finalEndpoint = def.endpoint; 
} 
関連する問題