木偶(没有方法渲染)

时间:2013-06-28 18:29:43

标签: backbone.js coffeescript marionette

我收到错误has no method 'render'但我不确定原因。唯一的区别是currentUser是否被传入。在这两种情况下,我都在getFooterView本地覆盖它,所以这似乎不是问题。

为什么这会产生影响?这与render方法有什么关系?

此代码有效:

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

  Show.Controller =
    showFooter: -> 
      currentUser = App.request "get:current:user"
      footerView = @getFooterView(currentUser)
      App.footerRegion.show footerView

    getFooterView: (currentUser) -> 
      currentUser = App.request "get:current:user"
      new Show.Footer
        model: currentUser

但这不是:

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

  Show.Controller =
    showFooter: -> 
      currentUser = App.request "get:current:user"
      footerView = @getFooterView
      App.footerRegion.show footerView

    getFooterView: -> 
      currentUser = App.request "get:current:user"
      new Show.Footer
        model: currentUser

这是我得到的错误:

Uncaught TypeError: Object function () {
    var currentUser;

    currentUser = App.request("get:current:user");
    return new Show.Footer({
      model: currentUser
    });
  } has no method 'render'

这是显示页脚:

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

  class Show.Footer extends Marionette.ItemView
    template: "footer/show/templates/show_footer"
    tagName: "span"

    modelEvents:
      "change" : "render"

0 个答案:

没有答案