Created
May 18, 2012 20:12
-
-
Save maxparm/2727373 to your computer and use it in GitHub Desktop.
Backbone - JQM - Disable jQuery Mobile router with Backbone.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- Meta --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Backbone - jQueryMobile - Router</title> | |
<!-- Style --> | |
<link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.1.0.min.css"> | |
<!-- Javascript --> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
// DISABLE JQM ROUTER | |
$(document).bind("mobileinit", function () { | |
$.mobile.ajaxEnabled = false; | |
$.mobile.linkBindingEnabled = false; | |
$.mobile.hashListeningEnabled = false; | |
$.mobile.pushStateEnabled = false; | |
$.mobile.changePage.defaults.changeHash = false; | |
}); | |
</script> | |
<script type="text/javascript" src="js/jquery.mobile-1.1.0.min.js"></script> | |
<script type="text/javascript" src="js/underscore-min.js"></script> | |
<script type="text/javascript" src="js/backbone-min.js"></script> | |
<script type="text/javascript"> | |
var TestRouter = Backbone.Router.extend({ | |
routes: { | |
"": "home", | |
"home": "home", | |
"test/:name": "test", | |
}, | |
initialize: function(){ | |
}, | |
home: function(){ | |
$.mobile.changePage($('#home-page'), {changeHash:false}); | |
}, | |
test: function (name) { | |
alert(name); | |
$.mobile.changePage($('#test-page'), {changeHash:false}); | |
} | |
}); | |
$(function(){ | |
var router = new TestRouter(); | |
Backbone.history.start(); | |
}); | |
</script> | |
</head> | |
<body> | |
<div data-role="page" id="home-page"> | |
<div data-role="header"><h1>Home</h1></div> | |
<div data-role="content" id="home"> | |
<p>this is the home page</p> | |
<p>go to <a href="#test/maxime">test page</a></p> | |
</div> | |
</div> | |
<div data-role="page" id="test-page"> | |
<div data-role="header" data-position="inline"> | |
<a href="#home" data-icon="home">Home</a> | |
<h1>Test Name</h1> | |
</div> | |
<div data-role="content" id="test">this is the test page showing the name parameter in the route</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment