Note that there are some explanatory texts on larger screens.

plurals
  1. POBackbone Marionette using Require.js, Regions and how to set up
    primarykey
    data
    text
    <p>I'm currently writing a Backbone Marionette app which ultimately amounts to about 6 different "screens" or pages which will often times share content and I am unsure of how to best structure and access Regions.</p> <p>I am using the app/module setup described here: <strong><a href="https://stackoverflow.com/questions/11070408/how-to-define-use-several-routings-using-backbone-and-requirejs">StackOverflow question 11070408: How to define/use several routings using backbone and require.js</a></strong>. This will be an application which will have new functionality and content added to it over time and need to be scalable (and obviously as re-usable as possible)</p> <p>The Single Page App I'm building has 4 primary sections on every screen: Header, Primary Content, Secondary Content, Footer.</p> <p>The footer will be consistent across all pages, the header will be the same on 3 of the pages, and slightly modified (using about 80% of the same elements/content) on the remaining 3 pages. The "morecontent" region will be re-usable across various pages.</p> <p>In my app.js file I'm defining my regions like so:</p> <pre><code>define(['views/LandingScreen', 'views/Header', 'router'], function(LandingScreen, Header, Router) { "use strict"; var App = new Backbone.Marionette.Application(); App.addRegions({ header: '#mainHeader', maincontent: '#mainContent', morecontent: '#moreContent', footer: '#mainFooter' }); App.addInitializer(function (options) { }); App.on("initialize:after", function () { if (!Backbone.History.started) Backbone.history.start(); }); return App; }); </code></pre> <p>Now, referring back to the app setup in the aforementioned post, what would be the best way to handle the Regions. Would I independently re-declare each region in each sub-app? That seems to be the best way to keep modules as independent as possible. If I go that route, what would be the best way to open/close or hide/show those regions between the sub-apps? </p> <p>Or, do I keep the Regions declared in app.js? If so, how would I then best alter and orchestrate events those regions from sub-apps? Having the Regions defined in the app.js file seems to be counter-intuitive to keeping what modules and the core app know about each other to a minimum. Plus, every example I see has the appRegions method in the main app file. What then is the best practice for accessing and changing those regions from the sub-app?</p> <p>Thanks in advance!</p>
    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