1

I'm trying to use backbone.Marionette to manage the layout of my website. and now I have a class named layout.js.coffee

class Views.Layout extends Marionette.Layout
  template: '#layout-template'
  regions:
    main: '#main-region'
    options: '#integration-options'

and I know I should have a template called layout-template. But where I can place this 'layout-template' file? Refer to the usage of CompositeView of marionette, I normally place the template in the templates folder and in the CompositeView, I can directly use

template: 'books/books'

So what is the meaning of '#' before the template? What should I name this template?

And if I want to show layout view, should I do something in controller like:

...
book.fetch
  success ->
    layout = new Books.Views.Layout
    layout.render()
    MyApp.main.show layout

Could anyone help me? I can not find any similar tutorial or example about this

1 Answer 1

1

The solution is below:

LayoutView extends Marionette.LayoutView
  regions:
    main: '#main'
    other: '#other'      
ViewA extends Marionette.CompositeView
ViewB extends Marionette.CompositeView

layoutView = new LayoutView
viewA = new ViewA
viewB = new ViewB

app.main.show layoutView
layoutView.main.show ViewA
layoutView.other.show ViewB

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.