NinjaCat
NinjaCat

Reputation: 10194

Stop main dblclick event from firing so that only child dbclick fires

I have a div called mydiv that serves as the container for my page... when someone double clicks, I do some stuff.

$('#mydiv').dblclick(function(e) {  

 // some stuff (**A**)
}

within that mydiv, I create jsplumb elements (which are just divs in themselves)

And when I double click on one of those, like this:

jsPlumb.bind("dblclick", function(e) { 
// some other stuff (**B**)
}

but the popup for both the A and B appear.

I'd like to prevent the popup in A from happening if B is dblclicked.

Upvotes: 0

Views: 149

Answers (1)

Joe Enos
Joe Enos

Reputation: 40393

You'll need to call stopPropagation:

jsPlub.bind("dblclick", function(e) {
    e.stopPropagation();
    // Do the rest of your stuff
});

This will prevent the event from getting bubbled up.

Upvotes: 1

Related Questions