The question is on the title. This is jsfiddle. This is the code:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Back button test</title>
<link href="//code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" rel="stylesheet">
<script src="//code.jquery.com/jquery-1.8.1.min.js"></script>
<script src="//code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<div id="home" data-role="page" data-add-back-btn="true">
<div data-role="header"><h1>header</h1></div>
<div data-role="content">content</div>
</div>
</body>
</html>
JQM only adds a back-button on pages beyond first view. If you add another page with data-add-back-btn="true"
it will show up:
<body>
<!-- -->
<div id="home" data-role="page" data-add-back-btn="true">
<div data-role="header"><h1>header</h1></div>
<div data-role="content">
content <a href="#page2">page2</a>
</div>
</div>
<div id="page2" data-role="page" data-add-back-btn="true">
<div data-role="header"><h1>Page 2</h1></div>
<div data-role="content">Back-button visible</div>
</div>
</body>
http://jsfiddle.net/c2pUt/4/
Here's a snippet from jquery-mobile-1.2.0.js (starting on row 4800):
// Auto-add back btn on pages beyond first view
if (o.addBackBtn && role === "header"
&& $(".ui-page").length > 1
&& $page.jqmData("url") !== $.mobile.path.stripHash(location.hash)
&& !leftbtn) {
backBtn = $("<a href='javascript:void(0);' class='ui-btn-left' data-" + $.mobile.ns + "rel='back' data-" + $.mobile.ns + "icon='arrow-l'>" + o.backBtnText + "</a>")
// If theme is provided, override default inheritance
.attr("data-" + $.mobile.ns + "theme", o.backBtnTheme || thisTheme)
.prependTo($this);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With