私はjsPlumbの問題に取り組んでいます。プログラムですべての要素の接続を削除しようとすると、Uncaught TypeErrorが発生します:undefinedのプロパティ'left'を読み取れません
いくつかの「ノード」(html要素)があり、それぞれに1つの入力エンドポイント(受け入れるエンドポイント)とnの出力エンドポイントがあります。各ノードの背後には、javascriptオブジェクトもあります。ソフトウェアに「選択済み」状態があります。ユーザーは複数のノードを選択でき、オブジェクトはselectedと呼ばれる配列にプッシュされます。削除キーのキーリスナーがあります。キーを押すと、選択したノードをループし、ノードを削除してエンドポイントを削除します。これは、接続がない場合はうまく機能しますが、接続がある場合はエラーになります。
出力エンドポイントは、メインノードの子HTML要素にアタッチされます…</ p>
多くのことを行うコードはたくさんありますが、関連する部分を共有しようと思います。
function Node(jsonFromServer){
/* … this is the constructor method… some code omitted*/
this.endpoints = [];
this.endpoints.push(jsPlumb.addEndpoint(this.el.attr("id"),targetEndpoint,{anchor:"TopCenter",uuid: this.el.attr("id") + "TopCenter"}));
this.addConnectionEndpoints();
}
Node.prototype.addConnectionEndPoints = function(){
//omitting code… loops through 'connections' that don't have 'has endpoint' marked….
this.endpoints.push(jsPlumb.addEndpoint(connection['el'].attr("id"),sourceEndpoint,{anchor:"RightMiddle",uuid:connection['el'].attr("id")+"RightMiddle"}));
connection.hasEndPoint = true;
}
これがセットアップでした。これが私が削除する方法です
when key pressed
If key is delete /* all this stuff works */
loop through selected array (the array of selected Node elements:works)
node.el.hide(250).remove();
loop through node's endpoints array
//endpoint is the correct object... proved with console.log
//the following line is the error
jsPlumb.deleteEndpoint(endpoint);
ajax call to server to delete stuff on the backend