Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: newHandlerInfo is undefined in emberjs

I came into a very strange bug: yesterday I coded the beginning of an ember.js app, tested it (everything was OK), and pushed it to my github repo. Today I just ran grunt serve (as I did yesterday) but I now get at the beginning the error TypeError: newHandlerInfo is undefined in my browser console.

I don't know what to show so you can check the code on the repo. https://github.com/OpenCubes/OpenCubes

After some debugging, I found that instead of throwing an error, it return an oldHandlerInfo in ember code which is null:

// Ideally we should throw this error to provide maximal
// information to the user that not enough context objects
// were provided, but this proves too cumbersome in Ember
// in cases where inner template helpers are evaluated
// before parent helpers un-render, in which cases this
// error somewhat prematurely fires.
//throw new Error("Not enough context objects were provided to complete a transition to " + targetRouteName + ". Specifically, the " + name + " route needs an object that can be serialized into its dynamic URL segments [" + names.join(', ') + "]");
return oldHandlerInfo; //  = UNDEFINED

And the error that should have been thrown is:

Not enough context objects were provided to complete a transition to view. Specifically, the mod route needs an object that can be serialized into its dynamic URL segments [mod_model.j_id]

like image 845
Vinz243 Avatar asked Mar 16 '26 12:03

Vinz243


1 Answers

Your slugs (:foo_id) should match a property name on the model (or you have to do all the serialize, it's easiest to just match). It should be unique and can find that resource without knowing anything else (i.e. a primary key). Really it makes the most sense to use the id of your record, :id (especially true since you're using Ember Data).

OpencubesDashboard.Router.map( ->
  @resource 'mods', path: '/'
  @resource 'mod', ->
    @resource 'mod', path: '/:id', ->
      @resource 'view', path: '/view'
      @resource 'edit', path: '/edit'

    @route('create')


)

Now your mod route, should use the slug name

OpencubesDashboard.ModRoute = Ember.Route.extend(
  model: (params) ->
    @get('store').find('mod', params.id)
)

Additionally your view and edit resources, are most likely editing/viewing the resource defined on the mod resource (maybe not, I'm just guessing).

OpencubesDashboard.ModViewRoute = Ember.Route.extend(
  model: (params) ->
    @modelFor('mod')
  setupController: (controller, model) ->
    controller.set 'model', model
    buffer = model.get('attributes').map (attr)->
      { key: attr.get('key'), value: attr.get('value') }
    controller.set 'buffer', buffer

)
like image 189
Kingpin2k Avatar answered Mar 18 '26 00:03

Kingpin2k



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!