2017-02-18 34 views

回答

0

如果你想進入任何鏈接,你有兩個選擇,那麼你可以刪除它們

_.each(cellView.paper.model.getLinks(), function(link) { 
     console.log(link.id, link.get('source'), link.get('target')) 
    }) 

OR 

_.each(cellView.paper.model.get('cells'), function(cell) { 
    if (cell instanceof joint.dia.Link) { 
     // cell is a link 
     console.log(cell.id, cell.get('source'), cell.get('target')) 
    } else { 
     // cell is an element 
     console.log(cell.id, cell.get('position'), cell.get('size'), cell.get('angle')) 
    } 
}) 

courtsey大衛Durman自己 https://groups.google.com/forum/#!topic/jointjs/cWJAK9gSC-Q

別人上圖你可以發出一個事件

graph.on('change:source change:target', function(link) { 
you can use link.remove() 
} 
1

是否graph.getCell(linkId)不是你想做什麼?

例如

graph.removeCells(graph.getCell(linkId)) 
+1

'removeCells'接受一個數組,它應該是'graph.removeCells([graph.getCell(linkId)])''''''graph.getCell(linkId).remove()'' –