Question

Im creating a gui questionnaire creator using JSPlumb and some of the answer types are yes/no. I'm trying to find out which connector stems from the yes source and which connector stems from the no source once jsPlumb.getConnections() is called.

If you see the image below the green connection on the question "Is today a weekend" represents a Yes and answer. I can find out the source and destination of both the yes and the no but im not sure how to tell which one is which.

Thanks in advance

enter image description here

Était-ce utile?

La solution 2

I have found a way to do the above but its a little dirty.

Get all connections and for each one get the connections endpoint html.

var outerHTML = $(this)[0].endpoints[0].canvas.outerHTML.toString();

From here check the html to see if it contains either the red or green colour set earlier.

If somebody knows a better way please let me know.

Autres conseils

Try to set different scope for the connections, as in your case two scopes "yes" and "no" during connection creation with scope option. While querying you can specify the required scope along with source or target element if needed, refer API DOC.

Example code:

var con=jsPlumb.getConnections({
        source:$(this),
        scope:"no"
});

Note that con is array of connections. Based on the variable con you can get the target innerHTML.

var HTML = $('#'+con[0].targetId).html(); // For single connection
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top