右的地方开始Backbone.history? [英] Right place to start Backbone.history?

查看:111
本文介绍了右的地方开始Backbone.history?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过的应用程序在任何addInitializer方法或开始Backbone.history初始化:后事件。什么是无论是在地方开始Backbone.history的优势和劣势?

I have seen application starting Backbone.history in either addInitializer method or in "initialize:after" event. What are the advantages and disadvantages of starting Backbone.history in either of the places?

在我的应用程序,我想使某些地区的布局,而应用程序正在等待大数据表得到填充。难道是有利的,等待开始Backbone.history某些地区得到渲染后?

In my application, I want to render certain regions in the layout while the application is waiting for big data list to get populated. Would it be advantageous to wait on starting Backbone.history after certain regions get rendered?

此外,这是验证用户正确的地方?

Also, which is the right place to authenticate user ?

推荐答案

这是更好地叫 Backbone.history.start()初始化:在,以确保所有的路由器在初始化过程中创建的。
如果您创建后路由器Backbone.history.start()不会触发他的路线。
你也可以阅读更多有关初始化过程中德里克·贝利的文章:的http://lostechies.com/derickbailey/2012/02/06/3-stages-of-a-backbone-applications-startup/

It is better to call Backbone.history.start() in initialize:after to be sure that all routers are created in initialization process. If you create router after Backbone.history.start() it will not trigger his routes. Also you can read more about initialization process in article of Derick Bailey: http://lostechies.com/derickbailey/2012/02/06/3-stages-of-a-backbone-applications-startup/

启动历史和渲染一些区域应该没有关系的。

Starting history and rendering some region should not related.

您可以在在onStart 事件 Marionette.Application 验证用户。

You can authenticate user in onStart event of Marionette.Application.

这篇关于右的地方开始Backbone.history?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆