Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: edf70f04b0
Fetching contributors…

Cannot retrieve contributors at this time

123 lines (104 sloc) 3.827 kb
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="../js/jquery.mobile.router.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
<script type="text/javascript">
var router=new $.mobile.Router({
"#localpage2(?:[?/](.*))?": {handler: "localpage", events: "bc,c,i,bs,s,bh,h"},
"#index": { handler: function(type){
console.log("Index has been "+(type=="pagehide"?"hidden":"shown"));
}, events: "h,s" }
},{
localpage: function(type,match,ui){
console.log("localpage2: "+type+" "+match[0]);
var params=router.getParams(match[1]);
console.log(params);
}
}, {
defaultHandler: function(type, ui, page) {
console.log("Default handler called due to unknown route ("
+ type + ", " + ui + ", " + page + ")"
);
},
defaultHandlerEvents: "s"
});
setTimeout(function(){
alert("adding a dynamic route to localpage3...");
router.add({
"#localpage3(?:[?/](.*))?": {handler: "localpage3", events: "s"}
},{
localpage3: function(type,match){
console.log("localpage3: "+type);
console.log(match);
}
});
},20000);
setTimeout(function(){
alert("deactivating router...");
router.destroy();
},120000);
</script>
</head>
<body>
<div data-role="page" id="index">
<div data-role="header">
<h1>Index</h1>
</div>
<div data-role="content">
<p>Page 1</p>
<p>The output of this page can be seen in your javascript console.</p>
<p>
<a href="#localpage2?param=value&param2=value">#localpage2 with params</a><br/>
<a href="#localpage2?foo=bar&bar=foo&foobarbaz&testarray[]=foo&testarray[]=bar">#localpage2 with params (with array)</a><br/>
The following route will be enabled after 20seconds<br/>
<a href="#localpage3?blablah">#localpage3 with params</a><br/>
The following link will show how a default route works<br/>
<a href="#localpage4">#localpage4</a><br/>
</p>
</div>
<div data-role="footer">
<h4>Index footer</h4>
</div>
</div>
<div data-role="page" id="localpage2" data-add-back-btn="true">
<div data-role="header">
<h1>Localpage 2</h1>
</div>
<div data-role="content">
<p>This is the localpage 2 in the multipage template.</p>
<p><a href="#index">Back to index</a></p>
</div>
<div data-role="footer">
<h4>Localpage 2 Footer</h4>
</div>
</div>
<div data-role="page" id="localpage3" data-add-back-btn="true">
<div data-role="header">
<h1>Localpage 3</h1>
</div>
<div data-role="content">
<p>This is the localpage 3 in the multipage template.</p>
<p><a href="#index">Back to index</a></p>
</div>
<div data-role="footer">
<h4>Localpage 3 Footer</h4>
</div>
</div>
<div data-role="page" id="localpage4" data-add-back-btn="true">
<div data-role="header">
<h1>Localpage 4</h1>
</div>
<div data-role="content">
<p>This is the localpage 4 in the multipage template.</p>
<p><a href="#index">Back to index</a></p>
</div>
<div data-role="footer">
<h4>Localpage 4 Footer</h4>
</div>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.