我有一个称为<代码>SearchApp的顶级应用,其次应用称为TeamApp
。 这些档案的结构类似:
search_app.js.coffee # The top-level application.
team_app/
app.js.coffee
team_list.js.coffee
team_invite.js.coffee
我在<代码>search_app.js.coffee上初步应用:
window.Domainer = {}
# This is the top level application.
Domainer.SearchApp = new Backbone.Marionette.Application()
# Assign a region to the Application.
Domainer.SearchApp.addRegions(stage: #stage )
html认为:
<script>Domainer.SearchApp.start({});</script>
The Submodule TeamApp
is set out over a several file (below). 问题在于<代码>中的一些档案 TeamApp 模块似乎没有能够在<代码>SearchApp上添加初始器。 从一个档案的初始化开始,但不是在另一个档案中,我可以<代码>console.log。
# team_app/app.js.coffee
Domainer.SearchApp.module "TeamApp", (TeamApp, SearchApp, Backbone, Marionette, $, _) ->
# Initializers
# ----------
SearchApp.addInitializer (options) ->
console.log "This will log when I call Domainer.SearchApp.start()"
# In coffeescript it s important to explicitly return.
return TeamApp
# team_app/team_list.js.coffee
Domainer.SearchApp.module "TeamApp", (TeamApp, SearchApp, Backbone, Marionette, $, _) ->
class CompactSearcher extends Marionette.ItemView
# ... various code relating to this view.
class TeamList extends Marionette.CollectionView
# various code relating to this view.
SearchApp.addInitializer (options) ->
console.log "This will never log for some reason."
return TeamApp
# team_app/invite_view.js.coffee
Domainer.SearchApp.module "TeamApp", (TeamApp, SearchApp, Backbone, Marionette, $, _) ->
class InviteView extends Marionette.ItemView
# ... various code relating to this view.
SearchApp.addInitializer (options) ->
console.log "This will never log either."
return TeamApp
不可能将一个单元分成多个档案? 这是我所能想象的唯一事情。 怎样才能造成问题?