Search code examples
javascriptjqueryjsplumb

jsPlumb multiple connections


I'm trying to do a connect pairs jQuery quiz, I found jsPlumb, but I'm trying to connect each question to an answer.

Here is my code: http://jsfiddle.net/xzf0ffcu/17/

    instance.makeSource("sourceWindow1", {
        filter:function(evt, el) {
            var t = evt.target || evt.srcElement;
            return t.tagName !== "A";
        },
        isSource:true
    });      

Does anybody has an idea how to do this?


Solution

  • You can add a simple loop that seems to work to allow you to connect all the questions to an answer. http://jsfiddle.net/xzf0ffcu/18/

    My update was to basically add the below function...

    for(QuestionCounter=1; QuestionCounter<=NumberOfQuestions; QuestionCounter++)
    {
      ...
    }
    

    I also had to update your variable names for the questions so they worked dynamically...

    var state = instance.toggleSourceEnabled("sourceWindow"+QuestionCounter);