jQM - Prevent event propagation
by Dragan Gaić
HTML
<!DOCTYPE html>
<html>
<head>
<title>jQM Demo 1</title>
<meta name="viewport" content="width=device-width"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<div data-role="page" id="page1">
<div data-role="header" data-position="fixed" data-fullscreen="true">
<h1>Styling test</h1>
</div>
<div data-role="content">
<div class="someDiv">
Click this DIV
</div>
</div>
<div data-role="footer">
</div>
</div>
<script>
</script>
</body>
</html>
CSS
.someDiv {
width: 300px;
height: 100px;
background-color: #aabbcc;
color: #112233;
margin-top: 200px;
}
JavaScript
$('#page1').live('pagebeforeshow',function(e,data){
$('.someDiv').live('click', function (e) {
alert('Event is not going to propagate to content div, thus not hiding a header');
event.stopPropagation();
event.stopImmediatePropagation();
});
});