Ember RSVP data


#1

I’m trying to get data from a multiple ajax calls but when i try to display it in handlebars i get nothing. The console log display the expected data

     model:function(params){

     

      return Ember.RSVP.hash({

        data1:  Ember.$.getJSON("file.php",{"action":"1",}),
        data2:  Ember.$.getJSON("file.php",{"action":"2"})

      })

    },

    setupController:function(controller,model){

    controller.set('model1', model.data1);
    controller.set('model2', model.data2);

    console.log(model);
}

#2

Perhaps you have to call this._super(controller, model); in your setupController function?


#3

tried with this._super(controller, model) but nothing change


#4

Can you show us a bit more of what you have going on like the templates and maybe some controller code.

Personally I’ve had better luck with {{model.data1}} and {{model.data2}} in the controller vs trying to not use the default model hook. To implement this you would just need to comment out your setup controller function. If it really bugs you to have the extra step you can alias data1 and data2 using Ember.computed.alias(‘model.data1’) in your controller.


#5

I guess you have to access the properties via the get method when setting on controller:

controller.set('model1', model.get('data1'));
controller.set('model2', model.get('data2'));

Ember-flavoured Handlebars do that for you.