我正在尝试禁用 jquerymobile 的 rounting,但出现错误加载页面,并且 url 没有被主干捕获。我已经禁用了 jqeurymobile 的所有参数,如在某些教程中阅读的那样。
在这里禁用jquerymobile:
require.config({
paths: {
jQuery: '../libs/jquery/jquery-loader',
jQueryMobile: '../libs/jquery.mobile/jquery.mobile-loader',
underscore: '../libs/underscore/underscore-loader',
Backbone: '../libs/backbone/backbone-loader',
order: '../libs/require/order-1.0.5',
text: '../libs/require/text-1.0.6',
async: '../libs/require/async',
//PhoneGap: '../libs/phonegap/phonegap-loader',
Handlebars: '../libs/handlebars/Handlebars',
templates: '../templates'
}
});
require(['order!jQuery'], function($) {
// jQueryMobile configuration
$(document).bind("mobileinit", function() {
$.mobile.ajaxEnabled = false;
$.mobile.autoInitializePage = false;
$.mobile.linkBindingEnabled = false;
$.mobile.hashListeningEnabled = false;
$.mobile.pushStateEnabled = false;
$.mobile.changePage.defaults.changeHash = false;
$.mobile.pageContainer = $("body");
// Remove page from DOM when it's being replaced, otherwise the DOM will contain
all of them
$('div[data-role="page"]').on('pagehide', function(event, ui) {
$(event.currentTarget).remove();
});
});
// We launch the App
// jQueryMobile is referenced in order to start its initialization
require(['underscore', 'Backbone', 'router', 'jQueryMobile'], function(_,
Backbone, AppRouter, jQueryMobile) {
document.addEventListener("deviceready", run, false);
run();
function run() {
var sync = Backbone.sync;
Backbone.sync = function(method, model, options) {
options.beforeSend = function (xhr) {
xhr.setRequestHeader('X-Parse-Application-Id', 'niI
BCf78Rfe1wu**yQWUrr6A3yyhex3M');
xhr.setRequestHeader('X-Parse-REST-API-Key', 'l4CgjESBwPYA**3Pq1V1LKHTvuhQj');
};
sync(method, model, options);
},
app = new AppRouter();
Backbone.history.start();
Parse.$ = jQuery;
Parse.initialize("niIBCf***7tbnyQWUrr6A3yyhex3M",
"HD4bsMvPh3T*YvT1MIdOh2GR");
}
})
});
在这里声明 url:
<div data-role="navbar" data-theme="d" data-position="fixed">
<ul>
<li><a href="#" data-icon="grid"></a></li>
<li><a href="#/insert" data-icon="home"></a></li>
<li><a href="#" data-icon="search"></a></li>
</ul>
</div><!-- /navbar -->