0

我的布局没有显示我的项目视图。

这是我的标记:

<div id="wrapper">
    <div id="header">header div</div>
    <div id="main">main div</div>
</div>

这是我的javascript:

var EventView = Backbone.Marionette.ItemView.extend({
    template: Handlebars.compile("Name of event: {{name}}"),
    model: new Backbone.Model({
        name: "Game"
    }),
});
var AppLayout = Backbone.Marionette.Layout.extend({
    template: '#wrapper',

    regions: {
        header: '#header',
        main: '#main'
    }

});
var layout = new AppLayout();
layout.render();
var event1 = new EventView();
layout.main.show(event1);

我想要的只是

<div id="main">Name of event: Game</div>
4

1 回答 1

1

我认为您首先需要在应用程序区域内插入布局。

App = new Backbone.Marionette.Application();
App.addRegions({
    centerRegion: '#center'
});

var layout = new AppLayout();
App.centerRegion.show(layout);
var event1 = new EventView();
layout.main.show(event1);
于 2013-07-25T15:29:03.337 回答