edit this page - page history - about editing

Extending App.reset() in EmberJS

EmberJS

If you want to extend App.reset() in your EmberJS application, you need to make sure that you extend the prototype of App, rather than the creation of your specific App. That is, instead of:

App = window.App = Ember.Application.create
  LOG_TRANSITIONS: true

  # NOTE will not work!
  reset: ->
    @_super()
    App.isEmbedded = null

You need to define both a prototype (which can access @_super()) and the creator:

# we need to extend so it's available to each instance of the class
AppPrototype = Ember.Application.extend
  reset: ->
    @_super()
    App.isEmbedded = null

App = window.App = AppPrototype.create
  LOG_TRANSITIONS: true

Otherwise you will get App is not defined errors. See also Understanding Ember.Object.
Categories: EmberJS | Javascript
edit this page - what links to here? - page history - top
Last edited by jevon jevon 41 months ago