0

I have created a view which supports drag and drop following the solution here. Now I am trying to set the drag image for each view based on its own content. Here is coffeescript for part of the code that I have issue with:

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')
  ...
})

As you can see I tried this solution, but it did not work. Here is the errors I get in both cases above:

TypeError: this.get is not a function
src: this.get('parentView.block.thumbnail')

I am using Ember 1.0pre1 I don’t know how to access parent level scope here, and there is probably something basic I am missing here. Any help would be appreciated.

Community
  • 1
  • 1
Aras
  • 5,878
  • 9
  • 49
  • 76

1 Answers1

0

It's not because of createElement at src: @get 'parentView.block.thumbnail', here this doesnt point to the current view(I guess it refers to window object, depends on ur code), better use it as a computed property

src: (->
  @get 'parentView.block.thumbnail'
).property()
Mudassir Ali
  • 7,913
  • 4
  • 32
  • 60