Note that there are some explanatory texts on larger screens.

plurals
  1. POEmberjs async routing
    primarykey
    data
    text
    <p>My problem is related with the issues <a href="https://github.com/emberjs/ember.js/pull/1183">#1183</a> and <a href="https://github.com/emberjs/ember.js/issues/1268">#1268</a> of emberjs.</p> <p>I have dynamic element at routes. All is ok if I navigate throuht application. The problem is when I reload a page or when a type the url. In that case the app enter in the deserialize function and load and object by their id, but this load is asynchronous.</p> <p>At issue <a href="https://github.com/emberjs/ember.js/issues/1268">#1268</a> lukemelia says <em>"you will need to make the result of your deserialize method implement the promises pattern"</em>.</p> <p>I try it but always loose context. My code is similar to:</p> <pre><code>page: Ember.Route.extend route: '/:alias' deserialize: (router, params) -&gt; page=App.Page.find(params.alias) $.when( page.get("isLoaded") ).done( () -&gt; console.debug(page.get("alias")) return page) loading: Em.State.extend </code></pre> <p>The router goes to loading state but then return with no context data. I think i doing something wrong. Possibly all is wrong.</p> <p>Can anybody help me? Is there and example?</p> <p>Thanks!</p> <p><strong>Resolved:</strong></p> <pre><code>page: Ember.Route.extend route: '/:id' deserialize: (router, params) -&gt; page=App.Page.find(params.id}) deferred = $.Deferred() page.addObserver("isLoaded", -&gt; deferred.resolve(page)) return deferred.promise() serialize: (router, page) -&gt; return {id: page.get("id") } connectOutlets: (router, page) -&gt; router.get('applicationController').connectOutlet context: page name: "page" loading: Em.State.extend connectOutlets: (router, context) -&gt; router.get('applicationController').connectOutlet(context: context, name: "loading") </code></pre> <p>While page is loading the active state is loading, when page finish loading, router load page state automatically.</p> <p>I hope this may help somebody</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload