Dear Pat,
I can only tell you about my own scenario.
My endpoints are created like this:
jsPlumb.makeSources(outputSockets, sourceEndPoints[0]);
jsPlumb.makeTargets(inputSockets, targetEndPoint);
Where in- and outputSockets are arrays of div, and the source- and targetEndPoint are defined as:
var sourceEndPoint = {
isSource: true
, maxConnections: 10
, dropOptions: {
tolerance: "pointer"
, hoverClass: "dropHover"
}
, endpoint: ["Dot", { radius: 3 }]
, hoverPaintStyle: connectorHoverStyle
, connectorHoverStyle: connectorHoverStyle
};
sourceEndPoints[0] = sourceEndPoint;
targetEndPoint = {
isTarget: true
, endpoint: ["Dot", { radius: 3 }]
};
I let the user create the connections. And let the user delete the container (the block). When that happens I call (mu-os and mu-is are the class names of the divs that hold the source and target):
$('#' + selectedBlock).find('.mu-os').each(function () {
jsPlumb.detachAllConnections($(this));
jsPlumb.unmakeSource($(this), false);
});
$('#' + selectedBlock).find('.mu-is').each(function () {
jsPlumb.detachAllConnections($(this));
jsPlumb.unmakeTarget($(this), false);
});
$('#' + selectedBlock).remove();
That works with just one change in the deleteEndpoint function, as described above:
if (newEndpoints.length === 0) {
// remove the element altogether
delete endpointsByElement[e];
} else {
endpointsByElement[e] = newEndpoints;
}
I also allow the user to start fresh. At first I did $('#drawing').empty(); but that failed the second time. Then I changed to loop over all 'blocks' and call my own delete function, and that worked (I left the empty() statement in, because I am paranoid).
Hope this helps.
Kind regards,
Jan