1
我试图弄清楚它应该是什么容易的东西。我有这个视图(使用火焰 - 我不知道这是否是它的一部分)。我想要做的是显示一个基于编号的链接列表,让用户点击并选择可用的图像。布局工作正常,所有的HTML是可以接受的,但是当我点击一个链接,我得到似乎无法通过匿名视图获取ember.js范围
Uncaught TypeError: Object <(subclass of Ember.View):ember9452> has no method 'becomeKeyResponder'
而且
App.Router:ember3456> could not respond to event App.ControllerA.jumpToImage in state root.visualGlossary.defaultState.
谷歌变成了这些错误没有什么。
jumpToImage = Flame.View.extend({
layout: {left: 0, top: 5, height: 26, width: 'auto'},
classNames: 'image-links'.w(),
handlebars: "\
{{#each App.ControllerA.content.images}}\
{{#view App.arrayIndexer contentBinding='this'}}\
<a {{action 'App.controllerA.jumpToImage' }} {{bindAttr data-index='view._parentView.contentIndex'}}>{{view.test}}</a>\
{{/view}}\
{{/each}}\
"
}),
这为控制器A(相关部分)
App.controllerA = Em.ObjectController.extend({
imageIndex: 0,
//assume content.images is an valid enumerable
jumpToIImage: function(e){
this.set('imageIndex', $(e.target).data('index'));
}
)}
和控制器B
Sylvius.arrayIndexer = Ember.View.extend({
content: null,
test: function(){
return this.getPath('_parentView.contentIndex') + 1
}.property(),
jumpToImage: function(e){
Sylvius.vgDisplayController.set('imageIndex', $(e.target).data('index'));
}
})