所以我有一个在应用程序中获取的集合,如下所示
module.exports = class Application extends Chaplin.Application
start: ->
# # You can fetch some data here and start app
# # (by calling `super`) after that.
Chaplin.mediator.styleCollection.fetch().then super在这个主控制器接管并将用户带到适当的页面之后,如下所示
module.exports = class HomeController extends Controller
beforeAction: ->
super
@reuse 'header', HeaderView, region: 'header'
@reuse 'nav', NavView, region: 'nav'
@reuse 'price', PriceView, region: 'price'
@reuse 'frame', FrameView, region: 'frame'
piece: ->
@view = new PieceView
region: 'main'
nextPage: "style"
@subscribeEvent "click:continue-btn", ()->
@redirectTo {url:"style"}
@publishEvent "update:progress", 25
, @现在,当我通过我的HomeController到达PieceView时,我希望Chaplin.mediator.styleCollection应该已经同步了,但是在重新加载的过程中,有几次很明显集合还没有准备好。所以我放入一些console.logs,这是我看到的
console.log Chaplin.mediator.styleCollection输出(到目前为止一切正常)
StyleCollection
_byId: Object
_events: Object
_previousSync: "syncing"
_syncState: "synced"
escape: function (value) {
length: 3
models: Array[3]
safe: function (value) {
__proto__: ctorconsole.log Chaplin.mediator.styleCollection.toJSON() (这就是问题所在)
Array[0] <<<< the collection has nothing in it. I first thought the collection could still be syncing but that is not the case because the previous log showd _syncState: "synced"有什么想法吗?
发布于 2014-07-12 03:26:16
好吧,这是一个愚蠢的修复。
在应用程序代码中,我执行了以下操作
Chaplin.mediator.styleCollection.fetch().then =>超级
https://stackoverflow.com/questions/24704852
复制相似问题