0

I'm facing a problem with emberJS and the Router.

My route architecture is the one below :

  • root
    • index
    • app
      • home
      • item
        • display/:id
        • edit/:id

When I initialy navigate to display/:id the URL is well written as below :

localhost/#/app/item/display/da083d21-afab-4620-8a85-6a4e6bfb95b9

Then I hit the refresh button of my browser and the URL is then written as

localhost/#/app/item/display/undefined

I have the following functions in my route to handle serialize/deserialize

deserialize:  function(router, context) {
    return App.Item.find(context.id);
},
serialize:  function(router, context){
    return { id: context.id };
}

When I log the context passed in serialize :

  • before the refresh : it is set to the right item
  • after the refresh : it is set to an element that does not contained the id (not my item)

So I guess I'm missing something to serialize my URL after page refresh.

Any lead ?

Thanks

sly7_7
  • 11,961
  • 3
  • 40
  • 54
Thomas
  • 1,410
  • 10
  • 24
  • could you log the context inside the deserialize method ? even better, could you provide a jsfiddle of you example ? – sly7_7 Dec 10 '12 at 17:28

1 Answers1

1

This question was already address in Emberjs async routing

Solution is to use a Deferred object and implement the loading state.

Hope that helps

Community
  • 1
  • 1
Thomas
  • 1,410
  • 10
  • 24