javascript - Require.js load timeout for jquery/underscore/backbone/parse modules -
uncaught error: load timeout modules: order!libs/jquery/jquery-min order!libs/underscore/underscore-min order!libs/parse/parse-min libs/jquery/jquery-min libs/underscore/underscore-min libs/parse/parse-min backbone http://requirejs.org/docs/errors.html#timeout
i have no 404 requests under network tab of chrome, , have no script errors, outside of common bugs/fixes problem (according requirejs.org).
when @ network, see scripts loaded in following order:
require.js main.js app.js <-- required main.js order.js <-- used in main.js require next 4 scripts (which aren't amd) jquery-min.js <-- required main.js underscore-min.js <-- required main.js backbone-min.js <-- required main.js parse-min.js <-- required main.js router.js login.js text.js
this seems right me. below code main.js
,app.js
, , router.js
.
main.js:
// author: thomas davis <thomasalwyndavis@gmail.com> // filename: main.js // require.js allows configure shortcut alias // usage become more apparent futher along in tutorial. require.config( { paths : { jquery : 'libs/jquery/jquery-min', underscore : 'libs/underscore/underscore-min', backbone : 'libs/backbone/backbone-min', parse : 'libs/parse/parse-min', templates : '../templates' } }); require( [ // load our app module , pass our definition function 'app', // plugins have loaded in order due non amd compliance // because these scripts not "modules" not pass values // definition function below 'order!libs/jquery/jquery-min', 'order!libs/underscore/underscore-min', 'order!libs/backbone/backbone-min', 'order!libs/parse/parse-min' ], function(app) { // "app" dependency passed in "app" // again, other dependencies passed in not "amd" therefore // don't pass parameter function app.initialize(); });
app.js:
// filename: app.js define( [ 'jquery', 'underscore', 'parse', 'router' ], function($, _, parse, router) { var initialize = function() { parse.$ = $; // initialize parse parse application javascript keys parse.initialize("hidden", "also hidden"); // pass in our router module , call it's initialize function router.initialize(); }; return { initialize : initialize }; });
router.js:
// filename: router.js define( [ 'jquery', 'underscore', 'backbone', 'parse', 'views/home/login', ], function($, _, backbone, parse, loginview) { var approuter = backbone.router.extend( { routes : { // default '*actions' : 'defaultaction' }, defaultaction : function(actions) { // have no matching route, lets display home page loginview.render(); } }); var initialize = function() { var app_router = new approuter; backbone.history.start(); }; return { initialize : initialize }; });
try use requirejs-jquery. it's version of requirejs ready work jquery , try use shim config.
see link: https://github.com/jrburke/require-jquery
shim config example:
require.config({ paths: { "jqueryui": "libs/jquery-ui", "jquery": "libs/jquery-1.9.1", "underscore": "libs/underscore-min", "backbone": "libs/backbone-min" }, shim: { jqueryui:{ deps: ["jquery"], exports:"$" }, underscore: { exports: "_" }, backbone: { deps: ["underscore", "jquery"], exports: "backbone" } } });
Comments
Post a Comment