我收到错误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"