【发布时间】:2012-11-22 01:44:01
【问题描述】:
我在solution here 之后创建了一个支持拖放的视图。现在我正在尝试根据每个视图自己的内容设置拖动图像。这是我遇到问题的部分代码的咖啡脚本:
App.BlockView = Ember.View.extend(App.Draggable, {
classNames: ['block'],
mouseDown: ->
console.log "clicked on #{@get 'elementId'} block and thumbnail is #{@get 'block.thumbnail'}" #this works
,
dragIconElement: Em.View.create({
attributeBindings: ['src'],
tagName: 'img',
#src: @get 'block.thumbnail', #this does not work
src: @get 'parentView.block.thumbnail', #this does not work either
}).createElement().get('element')
...
})
如您所见,我尝试了this solution,但没有成功。这是我在上述两种情况下遇到的错误:
TypeError: this.get is not a function
src: this.get('parentView.block.thumbnail')
我使用的是 Ember 1.0pre1 我不知道如何在此处访问父级范围,并且我可能在这里缺少一些基本的东西。任何帮助将不胜感激。
【问题讨论】:
-
当你说 @get('block.thumbnail') 是 App.Draggable mixin 的属性吗?
-
@Unspecified 不,它是父视图的属性。如您所见,我可以直接从 mouseDown 函数访问它。
-
按父视图我的意思是
App.BlockView
标签: ember.js