I have a simple code where i use Phonegap/Apache Cordova with chocolate chip UI. i call father from grandfather and son from father so its like Grandfather -> father -> son Everything working fine. But there is a problem in back button. i cannot come back from father to grandfather or (from son to father). any idea ?
the code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="msapplication-tap-highlight" content="no">
<title>ChocolateChip-UI Android</title>
<link rel="stylesheet" href="chui/chui-ios-3.5.2.min.css">
<script src="chui/jquery-2.1.0.min.js"></script>
<script src="chui/chui-3.5.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script>
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){}
$(function() {
});
</script>
</head>
<body>
<nav class="current">
<h1>Family Tree</h1>
</nav>
<article id="main" class="current">
<section>
<ul class='list' role='list'>
<li class='comp' data-goto="grandfather">
<div>
<h3>Grandfather</h3>
</div>
<aside>
<span class='nav'></span>
</aside>
</li>
</ul>
</section>
</article>
<nav class='next'>
<a href='#' class='button back'>Navigation</a>
<h1>Family Tree</h1>
</nav>
<article id="grandfather" class='next'>
<section>
<ul class='list' role='list'>
<li class='comp' data-goto="Father1">
<div>
<h3>Father1</h3>
</div>
<aside>
<span class='nav'></span>
</aside>
</li>
<li class='comp' data-goto="Father2">
<div>
<h3>Father2</h3>
</div>
<aside>
<span class='nav'></span>
</aside>
</li>
<li class='comp' data-goto="Father3">
<div>
<h3>Father3</h3>
</div>
<aside>
<span class='nav'></span>
</aside>
</li>
</ul>
</section>
</article>
<nav class='next'>
<a href='#' class='button back'>Navigation</a>
<h1>Family Tree</h1>
</nav>
<article id="Father1" class='next'>
<section>
<ul class='list' role='list'>
<li class='comp' data-goto="main">
<div>
<h3>Son1</h3>
</div>
<aside>
<span class='nav'></span>
</aside>
</li>
<li class='comp' data-goto="main">
<div>
<h3>Son2</h3>
</div>
<aside>
<span class='nav'></span>
</aside>
</li>
<li class='comp' data-goto="main">
<div>
<h3>Son3</h3>
</div>
<aside>
<span class='nav'></span>
</aside>
</li>
</ul>
</section>
</article>
<nav class='next'>
<a href='#' class='button back'>Navigation</a>
<h1>Family Tree</h1>
</nav>
<article id="Father2" class='next'>
<section>
<ul class='list' role='list'>
<li class='comp' data-goto="main">
<div>
<h3>Son4</h3>
</div>
<aside>
<span class='nav'></span>
</aside>
</li>
<li class='comp' data-goto="main">
<div>
<h3>Son5</h3>
</div>
<aside>
<span class='nav'></span>
</aside>
</li>
</ul>
</section>
</article>
<nav class='next'>
<a href='#' class='button back'>Navigation</a>
<h1>Family Tree</h1>
</nav>
<article id="Father3" class='next'>
<section>
<ul class='list' role='list'>
<li class='comp' data-goto="main">
<div>
<h3>Son6</h3>
</div>
<aside>
<span class='nav'></span>
</aside>
</li>
</ul>
</section>
</article>
</body>
</html>
Your back button doesn't need an href, and it will interfere with the built-in navigation. Chui.js takes care of the navigation behind the scenes. Take a look at the event handler for the back button press.
/////////////////////////// // Initialize Back Buttons: /////////////////////////// $('body').on('singletap', 'a.back', function() { if (this.classList.contains('back')) { $.UIGoBack(); } });
From the documentation for how to include a back button in your navigation bar
<nav class='current'> <a class='button back'>Back</a> <h1>Candies</h1> </nav>