I'm building a page where I want to utilize taphold to launch a contextMenu. However, when an element is inside a parent the taphold propagates to this parent. I want to prevent this.
so when a user holds the child, ONLY the child taphold function should launch, and when the user holds the parent ONLY the parent should launch.
I tried el.stopPropagation() and el.stopImmediatePropagation(), but both didn't stop the taphold from propagating to the parent.
This fiddle will show the problem. Holding the green child also triggers the taphold of the red parent
The fiddle shows two divs:
<div class='parent'>
<div class='child'></div>
</div>
and uses this code:
$('.parent').on('taphold', function( el ){
alert( 'parent' );
});
$('.child').on('taphold', function( el ){
alert( 'child' );
});
if you tap and hold the green div the red will also trigger, which is not what I want.