I'm working with jsPlumb and Javascript to implement a simple drag and drop interface of elements where connections can be made amongst each other. I would like to know how I could get the connection details of the sources and the targets when the 'setting-like' button on each dropped element is clicked.
In the above canvas, if the settings icon of the "Empty Query" is clicked, I need to retrieve the connection info such
in-connector:
source id - in connector id itself & target id- "Pixar" element's connector id
out-connector:
source id - out connector id itself & target id- "Paramount" element's connector id
JS Function
function dropCompleteQueryElement(newAgent,i,e)
{
$(droppedElement).draggable({containment: "container"});
var finalElement = newAgent;
r++; q++;
var connectionIn = $('<div class="connectorIn">').attr('id', i + '-in').addClass('connection').text("in");
var connectionOut = $('<div class="connectorOut">').attr('id', i + '-out').addClass('connection').text('out');
finalElement.css({
'top': e.pageY,
'left': e.pageX
});
finalElement.append(connectionIn);
finalElement.append(connectionOut);
$('#container').append(finalElement);
jsPlumb.draggable(finalElement, {
containment: 'parent'
});
jsPlumb.makeTarget(connectionIn, {
anchor: 'Continuous'
});
jsPlumb.makeSource(connectionOut, {
parent:finalElement,
anchor: 'Continuous'
});
var myNode = document.getElementById("lot");
var fc = myNode.firstChild;
while( fc ) {
myNode.removeChild( fc );
fc = myNode.firstChild;
}
}
newAgent is the element dragged from the and the toolbox before the icons and labels are appended and the finalElement is the element dropped on the canvas.