gpt4 book ai didi

backbone.js - 将 Backbone.Marionette 布局附加到 "body"

转载 作者:行者123 更新时间:2023-12-05 00:32:39 42 4
gpt4 key购买 nike

我有一个 Marionette 布局,我想直接将其附加到页面元素。

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 上,而我已经将 body 用作“el”,因为我不需要额外的包装器。

最佳答案

您需要设置 el在 View 的定义中,而不是在初始值设定项中。


App.Views.Layouts.Unauthenticated = Backbone.Marionette.Layout.extend
el: "body"
template: "layouts/unauthenticated"
regions: ...

关于backbone.js - 将 Backbone.Marionette 布局附加到 "body",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13192863/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com