Search code examples
jsplumb

jsplumb: set label on multiple overlays sets the label on all overlays to the same thing


In my bind:

jsPlumb.bind("connection", function(e) { 
   jsPlumb.select(e).addOverlay(
       ["Label", {
       label: "my label",
       location: 0.5,
       cssClass: 'aLabel',
       id: uuid_line
       }]
);

I set that label to "my label". If I draw another connection between the same source and target nodes, and do this:

jsPlumb.bind("connection", function(e) { 
   jsPlumb.select(e).addOverlay(
       ["Label", {
       label: "my label2",
       location: 0.5,
       cssClass: 'aLabel',
       id: uuid_line2
       }]
);

Both labels on the overlay are set to "my label2".

I must be missing something obvious. Can anyone help?


Solution

  • Fixed this by changing:

    jsPlumb.select(e).addOverlay(
    

    to:

    con.addOverlay(
    

    where:

    var con=e.connection;