2014-06-09 84 views
1

我正在學習用木偶和Rails骨幹作爲後端,使用截屏和我堅持了這個錯誤:木偶:未捕獲的ReferenceError

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_app.js.coffee

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

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

    FooterApp.on "start", -> 
     API.showFooter() 

show_controller.js.coffee

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

    Show.Controller = 

     showFooter: -> 
      console.log 'test' 

我花了很多時間搞清楚什麼是錯的,但仍然沒有任何線索..

回答

1

在你的代碼尚未初始化控制器在任何時候,它應該多讀這樣的

API = 
    showFooter: -> 
     new FooterApp.Show.Controller 

了一下,然後在頁腳控制器,你可以有一個初始化函數,將顯示它

initialize: -> 
    console.log 'test' 
相關問題