Hareeshchandera / jsplumb

Automatically exported from code.google.com/p/jsplumb
0 stars 0 forks source link

Question: About overlays events #175

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
1. Is there any way to access the "Label"  by overlays event such as "click" 
event
2. Is there any way to access the connection by overlays event such as "click" 
event
jsPlumb.Defaults.Overlays = [
                [ "Arrow", { 
                    location:1,
                    id:"arrow",
                    length:14,
                    foldback:0.8
                } ],
                [ "Label", 
                    { 
                        location:0.8,
                        label:"delete", 
                        id:"labeltool2",
                        cssClass:"connectorLabelDelete",
                        events:{
                        "click":function() { 

                            var bool=confirm("delete?");
                            if(bool) {
                               //todo  detach the connection
                              // jsPlumb.detach( $("#"+ arguments[0].id).parent);  
                            }}

                         }

                    }]
            ];

Original issue reported on code.google.com by chaoy...@gmail.com on 13 Jan 2012 at 9:55

GoogleCodeExporter commented 8 years ago
Hi,

are you asking whether or not the label is provided in the event callback?

Original comment by simon.po...@gmail.com on 13 Jan 2012 at 8:34

GoogleCodeExporter commented 8 years ago
Thanks for you reply:
  I mean  
1. i want to detach the connection by the label event on this connection
2. i want to change the "Label" title on label event 

is it possible to do the two  in the Connection--> overlays --> 
"Label"-->Events-->"Click"

Original comment by chaoy...@gmail.com on 14 Jan 2012 at 9:37

GoogleCodeExporter commented 8 years ago
the label is passed back as the first argument in the event callback:

"click":function(label, originalEvent) { 

                            var bool=confirm("delete?");
                            if(bool) {
                               //todo  detach the connection
                              // jsPlumb.detach(label.connection);    <-- 'connection' is a member of label.
                            }}

                         }

you can change the label's title with this method:

label.setLabel("new label");

Original comment by simon.po...@gmail.com on 14 Jan 2012 at 11:12

GoogleCodeExporter commented 8 years ago
Thank you very much!
Fixed!

Original comment by chaoy...@gmail.com on 16 Jan 2012 at 1:07

GoogleCodeExporter commented 8 years ago
you're welcome.  closing this out.

Original comment by simon.po...@gmail.com on 16 Jan 2012 at 1:58

GoogleCodeExporter commented 8 years ago
I have exact same issue. I don't see connection as a member of label???

// jsPlumb.detach(label.connection);    <-- 'connection' is a member of label.

Original comment by th71...@gmail.com on 1 Nov 2013 at 2:10

GoogleCodeExporter commented 8 years ago
it was changed to `component` a while ago.

Original comment by simon.po...@gmail.com on 1 Nov 2013 at 8:00