Reputation: 16469
Using jQuery mobile I'm creating a simple form that displays a collapsible list of car brands. Under this collapsible list will be the different models of the car brand. When one clicks/touches the car model, I want to be able to load to another page that will display some statistics of the certain car model. I'm not quite sure how to link to another page/HTML file. This is what I have so far:
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<style>
a.test {
font-weight: bold;
}
</style>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1"> <!-- view port sets the bar as wide as the screen -->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile- 1.3.2.min.css" />
<script src="jquery.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"> </script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Dream Ride</h1>
</div><!-- /header -->
<div data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="arrow-d" data-expanded-icon="arrow-u">
<h1>Honda</h1>
//code to link to other HTML files or pages
<div data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="arrow-d" data-expanded-icon="arrow-u">
<h3>BMW</h3>
<p>sdfsdf</p>
</div>
<div data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="arrow-d" data-expanded-icon="arrow-u">
<h3>Mercedez</h3>
<p>sdfsdf</p>
</div>
<div data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="arrow-d" data-expanded-icon="arrow-u">
<h3>Audi</h3>
<p>sdfsdf</p>
</div>
<div data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="arrow-d" data-expanded-icon="arrow-u">
<h3>Ferrari</h3>
<p>sdfsdf</p>
</div>
<div data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="arrow-d" data-expanded-icon="arrow-u">
<h3>Lamborghini</h3>
<p>sdfsdf</p>
</div>
</div><!-- /content -->
<div data-role="footer">
<h4>My Footer</h4>
</div><!-- /footer -->
</div><!-- /page -->
</body>
</html>
Upvotes: 0
Views: 195
Reputation: 134
I'm assuming your talking about loading a page without reloading the whole document. To do that with jQuery Mobile create another <div data-role="page">
and give it an id attribute. In your first page just link to it with an anchor tag: <a href="#pageid"></a>
Example:
<div data-role="page" id="one">
<div data-role="content">
<h1>Page One</h1>
<a href="#two">Go to page two</a>
</div>
</div>
<div data-role="page" id="two">
<div data-role="content">
<h1>Page Two</h1>
<a href="#one">Go to page one</a>
</div>
</div>
Demonstration on JSFiddle: http://jsfiddle.net/VaeCL/
Upvotes: 1