Backbone Layout Manager嵌套视图无法呈现

时间:2014-02-26 16:43:29

标签: javascript backbone.js backbone-layout-manager nested-views

我正在使用Backbone和Backbone布局管理器插件。我正在尝试渲染包含嵌套视图的视图。

var ContentView = Backbone.Layout.extend({
    tagName: 'div',
    className: 'container',

    views: {
        "contactList": new ContactListView({
                            collection: new Contacts()
                        })
    },

    changeContactSelection: function(one){
        console.log('dsdssdsdssd');
        console.log(one);
    },

    initialize: function (){
        this.listenTo(this.getView("contactList"), "change:selectedContact", this.changeContactSelection);
    }
});

此代码运行时没有错误,但屏幕上没有任何内容呈现。我也尝试过添加

beforeRender: function (){
    this.insertView("contactList");
}

但这会导致以下错误

  

未捕获错误:已定义与选择器'contactList'关联的参数,并且已定义视图。为manage个实例

设置true属性为Backbone.View

但是,ContactListViewBackbone.Layout,而不是Backbone.View

0 个答案:

没有答案