Hi all.
I'm looking for a solution on a tap / tap-toggle conflict. I have a simple test page containing a header and an html element. Something like this :
- <div data-role="page" data-fullscreen="true" >
- <div data-role="header" data-position="fixed">
- <h1>My extraordinary page</h1>
- </div>
- <div data-role="content">
- <div id="myElement">My element</div>
- </div>
- </div>
- </div>
As per the documentation, when I tap the screen, the header toggles between visible and hidden.
On my element, I bind a tap event. Something like this :
- $('#myElement').bind('tap', function(e) {
- // Do something
- });
Both events work as expected, but too perfectly for me :D
In fact I'm looking for a solution to prevent the toggle event to be fired when I tap the #myElement element. The expected behavior is :
- If I tap #myElement, only the bound event is fired. The header toolbar is NOT toggled and keeps its current position.
- If I tap anywhere else, the header toolbar is toggled (default behavior)
I tried to add preventive actions to the bound tapped event, such as preventDefault or stopPropagation, but these actions do not have any effect on the toolbar :
- $('#myElement').bind('tap', function(e) {
- // Do something
- e.stopPropagation(); // Has no effect on the toolbar
- });
Does anyone think of a possible solution ?
Thanks in advance !