问题描述:

I'm trying to upgrade my app from Ember 1.6.0 to 1.7.0 (and eventually 1.8.1) and I'm running into some issues. In the template of a component I'm using:

{{action 'someMethodOnParentView' target=view.parentView}}

The template looks something like:

{{#parent-component}}

{{#child-component}}

<a href='#'>{{action "actionOnParentComponent" target=view.parentView}}>Click me</a>

{{/child-component}}

{{/parent-component}}

And ParentComponent has:

ParentComponent = Ember.Component.extend({

actions: {

actionOnParentComponent: function(){ console.log('do stuff');}

}

});

This was working correctly in 1.6.0, but since the update, whenever I click the element, I get:

Cannot read property 'send' of undefined

It seems like view and therefore view.parentView are null, or at least that's what I'm guessing from trying to output {{view}} and {{view.parentView}}.

Here's a JSBin of my situation working in 1.6.0 and not working in 1.7.0.

Any ideas?

网友答案:

Block components keep the context of their parent, in other words, the entire context here is the application view.

http://emberjs.jsbin.com/rixiliniji/1/edit?html,js,output

You'll need to rethink your structure (or hack it ;) http://emberjs.com/guides/components/wrapping-content-in-a-component/

相关阅读:
Top