Reputation: 403
Iam building my first mobile application so far and have no clue if my solution is good or not.
I used one single template(html file) with only one data-role="page". Each content element is just a div which gets hidden or shown via javascript. Please check following code to make it clear. This is also the entry point of my application.
$(document).delegate("#index", "pageinit", function(event, ui) {
initRotation();
initNavigation();
initImpressum();
initService();
cookie = null;
......
isLoggedIn(); //returns cookie = true || false
if (cookie == null) {
$('#login').show();
$('#home, #foot, #service').hide();
initRegistration();
} else {
$('#login, #service').hide();
$('#foot, #home').show();
$('#naviHome').addClass("ui-btn-active"); // ui-state-persist?!
createHomeContentFromServer();
}
});
I have several problems now.
Upvotes: 1
Views: 475
Reputation: 3297
Your app is slow because it is loading that one big page each time. The page init is firing multiple times probably because you are reloading that one big page each time you click a link.
In JQM, you have many data-role="page", not just one. Below is the standard template that Dreamweaver CS6 produces. It uses the JQ & JQM CDN's and is formatted for four pages. It should give you a good start:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery Mobile Web App</title>
<link href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css"/>
<script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js" type="text/javascript"></script>
</head>
<body>
<div data-role="page" id="page">
<div data-role="header">
<h1>Page One</h1>
</div>
<div data-role="content">
<ul data-role="listview">
<li><a href="#page2">Page Two</a></li>
<li><a href="#page3">Page Three</a></li>
<li><a href="#page4">Page Four</a></li>
</ul>
</div>
<div data-role="footer">
<h4>Page Footer</h4>
</div>
</div>
<div data-role="page" id="page2">
<div data-role="header">
<h1>Page Two</h1>
</div>
<div data-role="content">
Content
</div>
<div data-role="footer">
<h4>Page Footer</h4>
</div>
</div>
<div data-role="page" id="page3">
<div data-role="header">
<h1>Page Three</h1>
</div>
<div data-role="content">
Content
</div>
<div data-role="footer">
<h4>Page Footer</h4>
</div>
</div>
<div data-role="page" id="page4">
<div data-role="header">
<h1>Page Four</h1>
</div>
<div data-role="content">
Content
</div>
<div data-role="footer">
<h4>Page Footer</h4>
</div>
Upvotes: 1