Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Backbone.js 连接主干。将木偶布局连接到;正文“;_Backbone.js_Marionette - Fatal编程技术网

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: ...