Search code examples
javascriptjqueryjsplumb

JsPlumb - Adding own selector function to dynamic anchor


Here is one of the sample of my jsfiddle I was trying out. I am trying to provide my own selector function for the dynamic anchor(It performs some operations).

{{{ http://jsfiddle.net/sudharsanam/8acjz/8/ }}}

This has some problem. When dynamic anchor are returned from the selector function, All connections attached to the source are updated with the same value. Can anyone help me in solving this issue??

Regards, Sudharsanam.N


Solution

  • Your connections are all updated to the same point since all connections use the same anchor for the source endpoint : the one defined in z. Another way to say it is that you keep using the same anchor (the one declared in source_endpoint options) to create connection.

    It seems hard to work around this problem since you are using custom dynamic positioning. In your case, you cannot define an anchor template in the endpoint options as you would do it for non-custom anchors.

    What I propose to you is to use the beforeDrop interceptor as an option of the makeSource command and create a new instance of the dynamic anchor there.

    Best