4

I have a marionette layout, which I want to attach directly to the element of the page.

App.Views.Layouts.Unauthenticated = Backbone.Marionette.Layout.extend
  template: "layouts/unauthenticated"
  regions:
   content: "#content"
   header: "#header"
   footer: "#footer"  
  views: {}

 initialize:->
  @el = $("body")
  @delegateEvents()

then later in the app, I do this

App.layouts.unauthenticated = new App.Views.Layouts.Unauthenticated()
App.layouts.unauthenticated.render()

The layout is not attached to the page. How do I attach it to the body, while I already used body as an "el", since I don't need extra wrappers.

4

1 回答 1

6

You need to set the el in the definition of the view, not in the initializer.


App.Views.Layouts.Unauthenticated = Backbone.Marionette.Layout.extend
  el: "body"
  template: "layouts/unauthenticated"
  regions: ...
于 2012-11-02T11:59:48.097 回答