2013-10-24 51 views
0

我想从我与Ember观点打电话给我的控制器的作用,但它说:灰烬查看没有找到控制器/动作

Uncaught TypeError: Cannot call method 'send' of null 

我只是找不到一个享有工作权路在余烬中。

我的看法布局具有类似电话:

<button type="button" {{action modalConfirmation target="view"}} class="btn btn-primary">Save changes</button> 

我的视图类试图调用控制器以这种方式:

this.get('controller').modalConfirmation(); 

我的控制器有这样的事情:

ProjEmber.BananasIndexController = Ember.ArrayController.extend({ 
    actions: { 
    showModal: function() { 
     modalinaView.title = "My Title"; 
     modalinaView.templateName = "any_template_you_wish"; 
     modalinaView.append(); 
    }, 
    modalConfirmation: function() { 
     console.debug('Action modalConfirmation'); 
    } 
    } 
}); 

OBS:如果我使用这样的助手追加我的视图,它会有效:

{{#view ProjEmber.ModalinaView title='A title'}} 
    A not so good application of a modal view. Just for the sake of illustration. 
{{/view}} 

你可以看到在Github上完整的源代码中,especifically这部分承诺: https://github.com/lucaspottersky/ember-lab/commit/4862426b39adc0bbcce0b4cc3fd0099439f8dd55#commitcomment-4421854

+0

当你追加被它正确地创建它的操作旁边? – Kingpin2k

回答

0

有一个很好的可能性,它的失败将身体内的追加,或者您烬应用的范围,其这就是为什么事件不会传播到你的动作散列。

你可以尝试appendTo( '主体')

0

你不应该访问视图这样

VAR modalinaView = this.container.lookup( '观点:modalina');

这个PR可以给你更多的见解。

您正在执行Stefanpenner在此commit中完成的操作。

And this是Wycats的回复。

或者,这answer可以帮助你在实例化模态