Layout and view management

后端 未结 1 1222
予麋鹿
予麋鹿 2021-01-26 11:34

I begin with Backbone and I would like to implement a simple application in order to manage users and products objects. The page layout is always the same : the header (top page

1条回答
  •  孤独总比滥情好
    2021-01-26 11:37

    A router shouldn't be used to manage the application initialization. You should be creating an application object that manages the initialization process, sets up the headers and menus that you always need, etc. (Note that Backbone doesn't include an object such as this. It's up to you to create this object).

    The router should only know what it absolutely needs to know, in order to get the application back to the state being requested.

    I've written a few articles on this, and though my articles do reference my Backbone.Marionette framework, the principles of what I'm saying apply to standard Backbone use as well:

    http://lostechies.com/derickbailey/2012/02/06/3-stages-of-a-backbone-applications-startup/

    http://lostechies.com/derickbailey/2012/01/02/reducing-backbone-routers-to-nothing-more-than-configuration/

    http://lostechies.com/derickbailey/2011/12/27/the-responsibilities-of-the-various-pieces-of-backbone-js/

    http://lostechies.com/derickbailey/2011/12/12/composite-js-apps-regions-and-region-managers/

    http://lostechies.com/derickbailey/2011/09/15/zombies-run-managing-page-transitions-in-backbone-apps/

    http://lostechies.com/derickbailey/2011/08/30/dont-limit-your-backbone-apps-to-backbone-constructs/

    I realize that I'm suggesting you read far more information than is probably necessary to directly answer you question. The combination of these articles, though, should inform you of a number of different ideas and perspectives that will help shape your use of Backbone so that you can avoid some of the common mistakes regarding routers, managing layout, closing views, etc.

    0 讨论(0)
提交回复
热议问题