2013-10-24 67 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可以幫助你在實例化模態