тому у мене є колекція, яку я беру в програмі, починаю так
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
, @
Тепер, коли я дістаюсь до PieceView через мійHomeController, я очікую, що 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__: ctor
console.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"
Будь-які думки?
Відповіді:
0 для відповіді № 1Ок, це було німе виправлення.
у коді програми я зробив наступне
Chaplin.mediator.styleCollection.fetch (). Тоді => супер