I'm trying to add confirmation dialog before deleting vertex
and link
for Finite State Machine demo
of Joint Js lib v-2.2
.
Source code ref:
https://resources.jointjs.com/demos/fsa
https://resources.jointjs.com/demos/joint/demo/fsa/src/fsa.js
I want to trigger built in remove event
only after users make confirmation on dialog.
I'm trying like
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();
}
});
I also tried it from here but not working. JointJS - handling a Link Delete click