Setting ID to endpoints

754 views
Skip to first unread message

SeaGull

unread,
Oct 24, 2012, 2:07:49 AM10/24/12
to jsp...@googlegroups.com
Hi.
There was a useful option in old versions of jsPlumb (ex.1.2.6) to set own "global" ID's to new endpoints.
Like this:
jsPlumb.addEndpoint("Node", {uuid: "MyID"});
alert($("#MyID").length); // 1

Is there a way to do this in current versions ?

Simon Porritt

unread,
Oct 24, 2012, 2:30:53 AM10/24/12
to jsp...@googlegroups.com
Yes, you can still do this.

Simon Porritt

unread,
Oct 24, 2012, 2:31:25 AM10/24/12
to jsp...@googlegroups.com
...oh but that does not become the ID of the endpoint.  You can't then use that UUID in a jQuery selector.

SeaGull

unread,
Oct 24, 2012, 2:49:34 AM10/24/12
to jsp...@googlegroups.com

You can't then use that UUID in a jQuery selector.

Very, very pity :(
It was really useful to work with enpoints throw direct jQuery selectors.

Thanks.

Simon Porritt

unread,
Oct 24, 2012, 2:52:20 AM10/24/12
to jsp...@googlegroups.com
I don't think you ever could, not even in 1.2.6.  What would you do with it through a jQuery selector?  It's not a DOM element.  

SeaGull

unread,
Oct 24, 2012, 3:13:09 AM10/24/12
to jsp...@googlegroups.com

I don't think you ever could, not even in 1.2.6.  What would you do with it through a jQuery selector?  It's not a DOM element. 
The canvas of the endpoint was a DOM-element. I was working with it.

<html>
<head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.jsPlumb-1.2.6-all.js"></script>
</head>

<body>
<div id="Node"></div>

<script>
jsPlumb.addEndpoint("Node", {uuid: "id_my"});
$("#id_my").css({"background-color":"blue", "opacity":0.3, "height":"100px"});
</script>

</body>
</html>

Simon Porritt

unread,
Oct 24, 2012, 3:15:51 AM10/24/12
to jsp...@googlegroups.com
The canvas of the endpoint still is a DOM element. But that code you have pasted there would never have worked.


Simon Porritt

unread,
Oct 24, 2012, 3:18:53 AM10/24/12
to jsp...@googlegroups.com
var e = jsPlumb.addEndpoint("Node", {uuid: "id_my"});

$(e.canvas).css(...)

would do what you want. But I don't recommend manipulating the canvas elements directly. If you want to change the appearance you can use the setPaintStyle method on the Endpoint:

e.setPaintStyle({fillStyle:"red", etc});

SeaGull

unread,
Oct 24, 2012, 3:22:01 AM10/24/12
to jsp...@googlegroups.com
Emm... is works. I've tested the code before posting it.

Simon Porritt

unread,
Oct 24, 2012, 3:25:12 AM10/24/12
to jsp...@googlegroups.com
with 1.2.6?

SeaGull

unread,
Oct 24, 2012, 3:35:29 AM10/24/12
to jsp...@googlegroups.com

with 1.2.6?

Yes, my code is working in 1.2.6.

Your variant with $(e.canvas) works in 1.2.6 and 1.3.15.

That will do ! Thanks a lot !
Reply all
Reply to author
Forward
0 new messages