1

背景

我正在尝试使用Backbone.Marionette.

这些模板呈现,但数据未填充到模板中。谁能说我做错了什么?

使用backbone.Marionette.handlebars插件。

代码

mws.app = new Backbone.Marionette.Application();

mws.app.addRegions({
    page: "#page",
    contentContainer: "#mws-content-container"
});

mws.views.pageView = Backbone.Marionette.ItemView.extend({
    template:{
        type: 'handlebars',
        template: Handlebars.templates.page,
        serializeData: function(){
            return {
                'baseurl': "http://www.overstock.com/yo",
                'content': "content...?",
                'current_year': new Date().getFullYear(),
            }
        }
    }
});

mws.views.oasisRender = Backbone.Marionette.ItemView.extend({
    template:{
        type: 'handlebars',
        template: Handlebars.templates.oasis,
        serializeData: function(){
            return {
                'img1src': mws.homeDir+'img/oasis_1.png',
                'img2src': mws.homeDir+'img/oasis_2.png',
                'img3src': mws.homeDir+'img/oasis_3.png'
            };
        }
    }
});      

mws.app.router = Backbone.Marionette.AppRouter.extend({
    appRoutes: {
        'home' : 'homeRender'
    },
    homeRender: function(){
        mws.app.contentContainer.show(new mws.views.oasisRender());
    }
});

mws.app.addInitializer(function(){
    mws.app.page.show(new mws.views.pageView());
    mws.app.contentContainer.show(new mws.views.oasisRender());

});

mws.app.start();
4

0 回答 0