endpoint IDs

78 views
Skip to first unread message

Mac

unread,
Feb 28, 2012, 5:50:09 AM2/28/12
to jsPlumb
Hi,

I'm using jsPlumb in my project and I would like to know from which
endpoint to which one is a connection made.

I'm trying to do this in the following way:


- setting a label to each connection and when is clicked it should
show the source ID and the target ID of that connection..

jsPlumb.Defaults.ConnectionOverlays = [
[ "Label",
{
label:"showIDs",
events:{
"click":function(c) {


alert(c.sourceId+" to "+c.targetId);

}

}

}]
];



but it doesn't work.. the result is an "undefined" value..

my endpoints are defined as:


var endpointOptions = { isSource:true,
endpoint:"Rectangle",
paintStyle:{ width:17, height:17, fillStyle:"#000" },
connectorOverlays:[[ "Arrow" ]],
isTarget:true };


jsPlumb.addEndpoint('someDiv',
endpointOptions);


How could I set that ID value to each EndPoint??

thanks in advance.

Simon Porritt

unread,
Feb 28, 2012, 6:26:27 AM2/28/12
to jsp...@googlegroups.com
The callback to the label event is the label overlay, not the
connection. You should use

c.connection.sourceId

and

c.connection.targetId

(i think - i haven't got the code in front of me)

Mac

unread,
Feb 28, 2012, 7:15:07 AM2/28/12
to jsPlumb
Thank you Simon!

Would you know why the getConnections() method returns "[object
Object],[object Object]" instead of the connection IDs?

I'm trying to set a scope but it still doesn't work.. :S

any idea?

Simon Porritt

unread,
Feb 28, 2012, 1:25:32 PM2/28/12
to jsp...@googlegroups.com
if you've got more than one scope in your setup (by specifying scope
on some function call), then getConnections will return an object
whose keys are the different scopes:

http://jsplumb.org/doc/content.html#connectionInfo

Reply all
Reply to author
Forward
0 new messages