Ember Ajax Calls running in serial

Setup:

  • blah is my ember app
  • find essentially calls Ember.$.ajax(url, params, method)
  • the find method isn’t a blocking call
  • Neither of the routes nor controllers have dependencies (needs) on each other
  • The meta and header are for the header and footer of the page. {{ partial ‘footer’ }} in the template

Problem:

  • I’m trying to figure out why the setupController (I tried activate as well) in ApplicationRoute isn’t being executed until after my ajax call returns from my CowRoutes model.

I can’t insert images, too new, but this shows how the requests look in chrome, http://i.imgur.com/pPYhJTK.png If I do the nasty hack commented out in the CowRoute they all fire at the same time.

Thing’s I’ve Tried:

  • If I move the code from the setupController into the model of CowRoute they all run in parallel (they don’t belong here at all, especially since they are header footer and I might hit a different route beside CowRoute).
  • I tried using Ember.RSVP.resolve on my find method, everything still works, it’s just still running in serial

ApplicationRoute

blah.ApplicationRoute = Ember.Route.extend({

    // setupController runs If a route handler's context changes
    setupController: function () {
        this.controllerFor('meta_property').set('model', blah.MetaProperty.find('meta_property'));
        this.controllerFor('header').set('model', blah.User.find("user"));
    }

CowRoute

blah.CowRoute = blah.Route.extend({
    model: function (params) {
        //this.controllerFor('meta_property').set('model', blah.MetaProperty.find('meta_property'));
        //this.controllerFor('header').set('model', blah.User.find("user"));
        
        return blah.Cow.find('cow', params);
        //return Ember.RSVP.resolve(blah.Cow.find('cow', params));
    }

With some hints by some Stackoverflowers it appears as if all models are resolved before the setupController is called. This makes sense since the setupController has the model as one of it’s parameters.