Hareeshchandera / jsplumb

Automatically exported from code.google.com/p/jsplumb
0 stars 0 forks source link

Different behaviour when creating connections #149

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, Simon.

I saw a different behaviour when I create 2 connections in 2 different ways. 
The difference I had noticed is that the canvas.src is sometimes missing (this 
is associated with enhacement 146 that I reported before).

The two ways I used is via programatted (the canvas.src is missing) and 
drag/drop by the user (the canvas.src is right!). I had created another 
jsfiddle to show you the problem: 
http://jsfiddle.net/danielmartinezruiz/AX7d9/5/

When the page is loaded, an empty alert is shown. This alert comes from 
jsPlumbConnection event and is showing conn.sourceEndpoint.canvas.src, so this 
is "". This is in the programatic connect creation. Also, the images specified 
in the endpoints are not used, and the default images are shown.

Now, if you drag/drop from BlockA2 to BlockA1 endpoints, the alert shows the 
image source.

I think the problem comes when the blocks are created (with theirs endpoints) 
and inmediately the connection.

Best regards.

Original issue reported on code.google.com by daniel.martinez.ruiz on 16 Nov 2011 at 12:11

GoogleCodeExporter commented 8 years ago
i think this is just caused by the asynchronous loading of the images.   look 
at this jsfiddle:

http://jsfiddle.net/sporritt/AX7d9/6/

there's a listener bound to the image's 'load' event.  when it fires, the src 
property has been set.

Original comment by simon.po...@gmail.com on 16 Nov 2011 at 12:34

GoogleCodeExporter commented 8 years ago
Oh! That's right, but the images still be different than I specified in the 
options of the addEndpoint call...

Original comment by daniel.martinez.ruiz on 16 Nov 2011 at 12:46

GoogleCodeExporter commented 8 years ago
jsPlumb.connect uses the default endpoint that you've setup - the green one.  
this is the image that is reported in the alert.  

the reason is that your connect call uses the ids of the two elements, so it 
creates new endpoints.  those ones you've already added are ignored.

if you want to use the endpoints you've created as the source and target, 
you'll have to pass them back from the addBlock method or something:

http://jsfiddle.net/sporritt/AX7d9/8/

Original comment by simon.po...@gmail.com on 16 Nov 2011 at 1:03

GoogleCodeExporter commented 8 years ago
Wow, I didn't know that that was the behaviour of the connect function. So, I 
was doing the connection in the wrong way. Thanks, Simon, I will use the 
function in this manner.

Please, discard this issue. It was my fault, not a really issue.

Thanks again for the support.

Best regards.

Original comment by daniel.martinez.ruiz on 16 Nov 2011 at 1:09

GoogleCodeExporter commented 8 years ago
ok cool.  closing this out.

Original comment by simon.po...@gmail.com on 16 Nov 2011 at 9:41