Backbone.js 连接主干。将木偶布局连接到;正文“;
我有一个木偶布局,我想直接附加到页面的元素上Backbone.js 连接主干。将木偶布局连接到;正文“;,backbone.js,marionette,Backbone.js,Marionette,我有一个木偶布局,我想直接附加到页面的元素上 App.Views.Layouts.Unauthenticated = Backbone.Marionette.Layout.extend template: "layouts/unauthenticated" regions: content: "#content" header: "#header" footer: "#footer" views: {} initialize:-> @el = $(
App.Views.Layouts.Unauthenticated = Backbone.Marionette.Layout.extend
template: "layouts/unauthenticated"
regions:
content: "#content"
header: "#header"
footer: "#footer"
views: {}
initialize:->
@el = $("body")
@delegateEvents()
然后在以后的应用程序中,我会这样做
App.layouts.unauthenticated = new App.Views.Layouts.Unauthenticated()
App.layouts.unauthenticated.render()
布局未附加到页面。
既然我已经使用body作为“el”,那么如何将它附加到body上,因为我不需要额外的包装器。您需要在视图的定义中而不是在初始值设定项中设置
el
App.Views.Layouts.Unauthenticated = Backbone.Marionette.Layout.extend
el: "body"
template: "layouts/unauthenticated"
regions: ...