Jquery mobile: How to set panel push content only not header and footer? - jquery-mobile

I have a simple page that has nav panel and i want to push the content only not including the header and the footer. This is my sample code:
<div data-role="page" class="jqm-demos" id="tpage" data-title="Panel fixed positioning" data-url="tpage">
<div id="myhead" data-role="header" data-position="fixed" style="min-height: 160px;">
Menu
<h1> Sample header </h1>
</div><!-- /header -->
<div role="main" class="ui-content jqm-content jqm-fullwidth">
<h1>content</h1>
</div><!-- /content -->
<div data-role="footer" data-position="fixed">
<h4>Fixed footer</h4>
</div><!-- /footer -->
<div data-role="panel" data-position="left" data-display="overlay" data-theme="b" id="nav-panel">
panel
</div><!-- /panel -->
</div>
I try to search but i what i found is overlay only not push.

add this :
/*jquery mobile fix for fixed header*/
div[data-role=header]{
position: absolute;
top: 0px;
z-index: 9999;
width: 100%;
}
div[data-role=page]{
position: relative;
}

Related

Dialog close went to previous page

Expected Scenario: I have two div in one page one is popup and other is the main page. When I click on popup popup should open and when i click close on pop up it should show the other div
Actual Scenario: WHen I close it doesnot show the other div instead it goes to the previous page
Using Jquery Mobile 1.3.0
$.mobile.changePage("#publishlogonmanage", { role: "dialog", transition:"slideup",reload:false,reverse: false,changeHash: false });
PopUP COde
<div data-role="page" id="publishlogonmanage" data-history="false" data-overlay-theme="b" data-theme="b">
<div data-role="header" data-theme="a">
<a data-icon="delete" id="logonClose" data-mini="true" data-theme="a" data-rel="back" data-role="button" class="ui-btn-left"></a>
<a data-icon="delete" data-theme="a" data-transition="flip" data-rel="back" data-mini="true" data-role="button" class="ui-btn-left" style="width:80px;" >Close</a>
</div>
<div data-role="content" style="padding: 0; margin: 0; background: #FFFFFF;">
This is Body
</div>
</div>
Main Page:
<div data-role="page" data-theme="b" id="MobilePage" data-overlay-theme="b">
<div data-role="header" data-position="fixed" data-tap-toggle="false" data-theme="a">
<div style="float: left; margin-left: 5px;"> Back</div>
<h1 id="title"> 10 </h1>
</div>
<div data-role="content" class="master-wrapper-page">
This is body
<div style="margin-top:7px;display:none;float: right !important; margin-left: 0px !important;overflow:ellipsis;white-space: nowrap;" data-close-btn="right" id="ManageLogon" data-mini="true" onclick="LoadDialog();" data-rel="popup"></div><img src="../../../images/logon-E.png" style="1px solid #666666;margin-top:3px;margin-right:-5px float: right;height:30px;width:30px;" id="logonexp" /></div>
</div>
</div>

Change page, the enhancement of the previous page is removed

page1 header:
<div data-role="header" data-theme="a" role="banner" class="ui-header ui-bar-a">
<h1 class="ui-title" role="heading" aria-level="1">Foo</h1>
</div>
after changing to page2,
$(":mobile-pagecontainer").pagecontainer("change", "#page2", { } );
page1 header becomes: (class removed)
<div data-role="header" data-theme="a">
<h1 class="ui-title" role="heading" aria-level="1">Foo</h1>
</div>
After going back to page1,
$.mobile.back();
the page1 header is not enhanced.
Thanks for help.

How do you make a flipswitch on the right corner of a fixed header in jQuery Mobile?

I have tried the following:
<div data-role="header" data-position="fixed" data-tap-toggle="false">
<h1>My Page</h1>
<label for="nfcSwitch" class="ui-hidden-accessible">NFC:</label>
<input data-role="flipswitch" name="nfcSwitch" id="nfcSwitch" data-on-text="NFC on" data-off-text="NFC off" type="checkbox" />
</div>
but it shows the flipswitch on the left, under the h1
HTML
<div data-role="header" data-position="fixed" data-tap-toggle="false">
<h1>My Page</h1>
<div class="switch">
<label for="nfcSwitch" class="ui-hidden-accessible">NFC:</label>
<input data-role="flipswitch" name="nfcSwitch" id="nfcSwitch" data-on-text="NFC on" data-off-text="NFC off" type="checkbox"/>
</div>
</div>
CSS
.switch
{
position: absolute;
top: 0px;
right: 0px;
}
JSFiddle

Button Floating When Toggling Header Jquery Mobile

I am trying to add a home button to the right of my header. I am also hiding a toolbar behind the header. Now when adding a home button to the header, its wont stay fixed on the header when toggling.
<div data-role="header">
<div data-role="navbar">
<ul>
<li>Settings
</li>
<li>Whatever
</li>
</ul>
</div>
<!-- /navbar -->
<h1>Hide the Toolbar</h1>
<a href="#Home" data-role="button" data-icon="home" data-iconshadow="false"
data-direction="reverse" onclick="empty()" data-transition="slide"
data-iconpos="notext" class="ui-btn-right">home</a>
</div>
<!-- /header -->
$(document).bind('pageinit', function (event) {
loadHomePage();
$("#HomeHeader").on("click", function () {
$("#navMainToolbar").slideToggle(200);
});
$("#navMainToolbar").on("click", function (e) {
e.stopPropagation();
});
});
Here is a demo of the issue.
You need to move the navbar outside of the header:
<div data-role="page">
<div data-role="navbar">
<ul>
<li>Settings
</li>
<li>Whatever
</li>
</ul>
</div>
<!-- /navbar -->
<div data-role="header">
<h1>Hide the Toolbar</h1>
<a href="#Home" data-role="button" data-icon="home" data-iconshadow="false"
data-direction="reverse" onclick="empty()" data-transition="slide" data-iconpos="notext"
class="ui-btn-right">home</a>
</div>
<!-- /header -->
<div data-role="content">
<p>Page content goes here.</p>
</div>
<!-- /content -->
<div data-role="footer">
<h4>Page Footer</h4>
</div>
<!-- /footer -->
</div>
<!-- /page -->
Example:
http://jsfiddle.net/DMUwp/11/

How to create div with 100% height with jquery mobile?

How to create div with id=test with 100% height?
<div data-role="page" id="device1">
<div data-role="header">
<h1>Title</h1>
</div><!-- /header -->
<div data-role="content">
<div data-role="fieldcontain">
<input type="range" name="slider1" id="slider1" value="0" min="0" max="255" />
</div>
<div id=test height=100%>
</div>
</div><!-- /content -->
<div data-role="footer" data-position="fixed">
</div><!-- /footer -->
</div><!-- /page -->
OK, here is what I have for you. Keep in mind though, if the content of the page is tall at all this might not be very usable. The swipe area is everything below the content. So as the content area gets bigger the swipe area gets smaller.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery Swipe</title>
<link href="jquery-mobile/jquery.mobile-1.0b3.min.css" rel="stylesheet" type="text/css"/>
<script src="jquery-mobile/jquery.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.0b3.min.js" type="text/javascript"></script>
<script src="phonegap.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
// Set the initial window (assuming it will always be #1
window.now = 1;
//get an Array of all of the pages and count
windowMax = $('div[data-role="page"]').length;
$('.swipeArea').bind('swipeleft', turnPage);
$('.swipeArea').bind('swiperight', turnPageBack);
});
// Named handlers for binding page turn controls
function turnPage(){
// Check to see if we are already at the highest numbers page
if (window.now < windowMax) {
window.now++
$.mobile.changePage("#device"+window.now, "slide", false, true);
}
}
function turnPageBack(){
// Check to see if we are already at the lowest numbered page
if (window.now != 1) {
window.now--;
$.mobile.changePage("#device"+window.now, "slide", true, true);
}
}
</script>
<style>
body, div[data-role="page"], div[data-role="content"], .swipeArea {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div data-role="page" id="device1"">
<div data-role="header">
<h1>Page One</h1>
</div>
<div data-role="content">
Content
<div class=swipeArea></div>
</div>
<div data-role="footer" data-position="fixed">
<h4>Page Footer</h4>
</div>
</div>
<div data-role="page" id="device2" style="height: 100%">
<div data-role="header">
<h1>Content 2</h1>
</div>
<div data-role="content" style="height: 100%">
Content
<div data-role="fieldcontain">
<label for="slider">Input slider:</label>
<input type="range" name="slider" id="slider" value="0" min="0" max="100" />
</div>
<div class=swipeArea></div>
</div>
<div data-role="footer" data-position="fixed">
<h4>Page Footer</h4>
</div>
</div>
<div data-role="page" id="device3" style="height: 100%">
<div data-role="header">
<h1>Content 3</h1>
</div>
<div data-role="content" style="height: 100%">
Content
<div class=swipeArea></div>
</div>
<div data-role="footer" data-position="fixed">
<h4>Page Footer</h4>
</div>
</div>
<div data-role="page" id="device4" style="height: 100%">
<div data-role="header">
<h1>Content 4</h1>
</div>
<div data-role="content" style="height: 100%">
Content
<div class=swipeArea></div>
</div>
<div data-role="footer" data-position="fixed">
<h4>Page Footer</h4>
</div>
</div>
</body>
</html>

Resources