1
votes

I'm currently using a ContainerView, that has a CollectionView, but would like to then have another View in the CollectionView's ItemView. I've changed the ItemView to a ContainerView, and appended the new View, but but I'm having trouble binding content from the parent Collection -> Container to the child View.

I can pass values, but for some reason bindings just barf.

Code:

App.MainView = Ember.ContainerView.extend({
    header: Ember.View.create({
        templateName: "headerView"
    }),

    list: Ember.CollectionView.extend({
        contentBinding: "parentView.content",
        itemViewClass: "App.childContainer",
        tagName: "table"
    }),

    footer: Ember.View.create({
        templateName: "footerView"
    })
});

App.childContainer= Ember.ContainerView.extend({
    templateName: "childContainer",
    didInsertElement: function() {
        //NOTE:: THIS WORKS 
        var v = App.childContainerItem.create({"content":this.get('content')});
        //NOTE:: THIS DOESN'T WORK 
        var v = App.childContainerItem.create({"contentBinding":"this.content"});
        this.get('childViews').pushObject(v);    
    }
}); 

App.childContainerItem= Ember.View.extend({
    didInsertElement: function() {
        console.log(this.get('content').get('value'));    
    }   
});

I get: TypeError: this.get("content") is undefined

I get the feeling I'm close, but just missing some silly thing. Can someone give me a knock on the forehead?

1
I can't realize what you want exactly here, could you post a complete jsfiddle please ? All I can say, is instead using 'this.content', simply try to use 'content' for the binding. - sly7_7

1 Answers

0
votes

You can get the html content of the view by adding this line didInsertElement function,

App.childContainerItem= Ember.View.extend({
    didInsertElement: function() {
        console.log(this.get('content').get('value'));    
    }   
});