我正在通过backbone.js和phonegap开发一个应用程序,并在eclipse的logcat控制台中出现此错误:
android.webkit.CallbackProxy 711<!> Uncaught Error: Backbone.history has already been
started at file:///android_asset/www/libs/backbone/backbone%201.0.0.js:1363
错误指示的代码是加载程序调用的主干库。
这是main.js,它是对Backbone.history的显式调用:
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',<--error indicate this library
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($) {
require(['underscore', 'Backbone', 'router'], function(_, Backbone, AppRouter) {
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',
'***S3VMk');
xhr.setRequestHeader('X-Parse-REST-API-Key', '**fIt1Gm');
};
sync(method, model, options);
},
Parse.$ = jQuery;
Parse.initialize("***iTS3VMk",
"***9qLN7Duy");
app = new AppRouter();
console.log("history");
Backbone.history.start();<--explicit call
}
});
});
骨干加载器:
define(['../libs/backbone/backbone 1.0.0'],
function () {
return Backbone.noConflict();
});