我试图在删除Joint Js lib v-2.2
的Finite State Machine demo
的vertex
和link
之前添加确认对话框。
源代码参考:
https://resources.jointjs.com/demos/fsa
https://resources.jointjs.com/demos/joint/demo/fsa/src/fsa.js的
我想触发built in remove event
只有在用户确认对话框。
我在努力
graph: any;
paper: any;
this.graph = new joint.dia.Graph;
this.paper = new joint.dia.Paper({
el: $('#paper'),
width: 800,
height: 600,
gridSize: 1,
model: this.graph,
background: {
color: 'rgba(0, 255, 0, 0.3)'
}
});
/* not working */
this.paper.on('tool:remove', function(linkView, evt) {
evt.stopPropagation();
if (confirm('Are you sure you want to delete this element?')) {
linkView.remove();
}
});
/* not working */
this.paper.on('element:delete', function(elementView, evt) {
evt.stopPropagation();
if (confirm('Are you sure you want to delete this element?')) {
elementView.model.remove();
}
});
字符串
我也试过从这里,但不工作。JointJS - handling a Link Delete click
1条答案
按热度按时间yh2wf1be1#
我假设你使用ToolsView的“Remove”按钮来删除图表上的元素。如果是这样,将“action”选项添加到“Remove”按钮构造函数中,如下所示:
字符串
完整的工作示例可以在这里找到:https://www.jointjs.com/blog/demo-friday-confirmation-dialogs