0
我管理應用程序中的一些快捷方式到控制器中。但是當用戶按下熱鍵組合時,我需要在視圖中運行特定的方法。emberjs如何在控制器和視圖之間進行通信?
例如,當用戶按下
Right arrow
我想leftScroll()我的觀點,但我有在控制器
actions: {
rightArrow: function(...) { }
}
一個動作我怎麼能調用一個方法到視圖?
我管理應用程序中的一些快捷方式到控制器中。但是當用戶按下熱鍵組合時,我需要在視圖中運行特定的方法。emberjs如何在控制器和視圖之間進行通信?
例如,當用戶按下
Right arrow
我想leftScroll()我的觀點,但我有在控制器
actions: {
rightArrow: function(...) { }
}
一個動作我怎麼能調用一個方法到視圖?
this.get('controller')
是你如何拿起相應的控制器中的觀點,所以你會開除它的作用裏面didInsertElement
例如
didInsertElement: function() {
var controller = this.get('controller');
$('body').keyDown(function(e) {
if(e.keyCode == 39) { // right
controller.send('rightArrow');
}
});
}