Skip to content Skip to sidebar Skip to footer

Persistent HTML Outside Of JQuery Mobile Pages

I want to include a bit of HTML outside of the
element on my main page. This HTML shouldn't be replaced when a new page is loaded in via ajax. The exam

Solution 1:

I don't think divs get replaced. For example, this will bring the first unseen div to the top:

http://jsfiddle.net/RQkrj/2/

<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link  href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<style>
.top {
    z-index: 999;
}
</style>
<script>
$('div#page').live('pageshow', function(event, ui) {
    $('div#doesNotGetRemoved').addClass("top");
});
</script>
</head>
<body>

<div id="doesNotGetRemoved" style="background: red; position: absolute;">This is a div</div>

<div id="page" data-role="page">

    <div data-role="header">
        <h1>My Title</h1>
    </div><!-- /header -->

    <div data-role="content">    
        <p>Hello world</p>        
    </div><!-- /content -->

</div><!-- /page -->

</body>
</html>

Post a Comment for "Persistent HTML Outside Of JQuery Mobile Pages"