App.CurtainView = Ember.View.extend
name: "CurtainView"
getName: ->
console.log @get("name")
App.ButtonView = App.CurtainView.extend
name: "ButtonView"
getName: ->
# Do something
@_super()
Returns on console:
ButtonView
…but I expect:
CurtainView
I guess this is a context issue – how can I make _super() using the parent objects context?
I don’t completely get your goal. This behavior is the same as you would expect with Ruby language, but indeed differs from what you would obtain with Java (assuming you would redefine the
nameattribute inButtonsubclass)…In fact, you have to be aware of the way the Ember’s object model is implemented to better understand the behavior you get:
The
_supercall applies by default to the object on which the current function has been called.You could override this default behavior by calling
getNamethroughapplyorcall, and passing the appropriated target. But it seems pretty weird to me…JSFiddle here