Search code examples
jqueryuser-inputjsplumb

jsPlumb - adding a string value to an edge


I am making a webapp using jQuery jsPlumb. I am interested in prompting the user to insert a value whenever the drag-and-drop a new edge. However, I am unsure how to do this.

Would anyone be able to help?

jsPlumb - http://www.jsplumb.org/demo/flowchart/dom.html

Thanks!


Solution

  • If by "drag-and-drop a new edge" you mean making a connection then you can use the connection event.

     jsPlumb.bind("connection", function (connInfo, originalEvent) {
         // you could ask for input here.
         var userText = prompt("Please enter your name", "Harry Potter");
         // If you want to put the text in  the overlay label on the 
          connInfo.connection.getOverlay("label").setLabel(userText);
    
     } );
    

    The above code should be able to get input from the user and set it into the overlay for the connection created.