Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to define/use several routings using backbone and requirejs
    primarykey
    data
    text
    <p>I divided my app in several apps.</p> <pre><code>main.js app.js app1/ |- routing |- controller |- app app2/ |- routing |- controller |- app </code></pre> <p>1) When I try to use the routers in <code>app1</code>, they work.<br> 2) When I try to use the routers in <code>app2</code>, they don't work.<br> 3) If I comment the line <code>'js/app1/routing',</code> in <code>main.js</code> the routers in <code>app2</code> work.</p> <p>Why do I get this behaviour?<br> Is there some example of app using multiple routing and requirejs on github?</p> <p>thanks.</p> <p>Here's my code:</p> <hr> <p>** main.js **</p> <pre><code>define([ 'js/app', 'js/app1/routing', // the routers in this app work 'js/app2/routing' // the routers in this app do not work but // if I comment the previous line (js/app1/routing',) // they works ], function (App) { "use strict"; App.initialize(); }); </code></pre> <hr> <p>** app.js **</p> <pre><code>define([], function () { "use strict"; var app = new Backbone.Marionette.Application(); return app; }); </code></pre> <hr> <p>** app1/rotuing **</p> <pre><code>define(['backbone','app1/controller'], function(Backbone, controller) { "use strict"; var Router = Backbone.Marionette.AppRouter.extend({ appRoutes: { '*defaults': 'index1' } }); return new Router({ controller: controller }); }); </code></pre> <hr> <p>** app2/routing.js ** </p> <pre><code>define(['backbone','app2/controller'], function(Backbone, controller) { "use strict"; var Router = Backbone.Marionette.AppRouter.extend({ appRoutes: { 'app2': 'index2' } }); return new Router({ controller: controller }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload