Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Backbone.js 木偶:未捕获的引用错误_Backbone.js_Coffeescript_Marionette - Fatal编程技术网

Backbone.js 木偶:未捕获的引用错误

Backbone.js 木偶:未捕获的引用错误,backbone.js,coffeescript,marionette,Backbone.js,Coffeescript,Marionette,我正在研究以木偶网和Rails作为后端的主干网,使用screencast,我遇到了这个错误: Uncaught ReferenceError: FooterApp is not defined 我的app.js.coffee代码: @Demo = do (Backbone, Marionette) -> App = new Backbone.Marionette.Application App.addRegions headerRegion: "#h

我正在研究以木偶网和Rails作为后端的主干网,使用screencast,我遇到了这个错误:

Uncaught ReferenceError: FooterApp is not defined 
我的app.js.coffee代码:

@Demo = do (Backbone, Marionette) ->

    App = new Backbone.Marionette.Application

    App.addRegions
        headerRegion: "#header-region"
        mainRegion: "#main-region"
        footerRegion: "#footer-region"

    App.addInitializer ->
        App.module("FooterApp").start()
        #App.execute "footer:show"

    App.on "initialize:after", ->
        if Backbone.history
            Backbone.history.start()

    App
footer\u app.js.coffee

@Demo.module "FooterApp", (FooterApp, App, Backbone, Marionette, $, _) ->
  @startWithParent = false

    API = 
        showFooter: ->
            FooterApp.Show.Controller.showFooter()

    FooterApp.on "start", ->
        API.showFooter()
@Demo.module "FooterApp.Show", (Show, App, Backbone, Marionette, $, _) ->

    Show.Controller = 

        showFooter: ->
            console.log 'test'
show_controller.js.coffee

@Demo.module "FooterApp", (FooterApp, App, Backbone, Marionette, $, _) ->
  @startWithParent = false

    API = 
        showFooter: ->
            FooterApp.Show.Controller.showFooter()

    FooterApp.on "start", ->
        API.showFooter()
@Demo.module "FooterApp.Show", (Show, App, Backbone, Marionette, $, _) ->

    Show.Controller = 

        showFooter: ->
            console.log 'test'

我花了很多时间找出了错误,但仍然没有任何线索。

在您的代码中,您在任何时候都没有初始化控制器,它应该读得更像这样

API = 
    showFooter: ->
        new FooterApp.Show.Controller
然后在页脚控制器中可以有一个初始化函数来显示它

initialize: ->
    console.log 'test'