1

I have a list of printers

GradingX.PrintersRoute = Ember.Route.extend({
    model: function () {
        var printerList = Em.A();

        //Ember.
        $.getJSON("http://localhost/printers").then(function (data) {
            data.forEach(function (item) {
                printerList.addObject(item);
            }), function () {
                alert("$.getJSON failed!");
            };
        });
        return printerList;
    },
});

That I'm trying to access from my header

GradingX.HeaderRoute = Ember.Route.extend({
    model: function () {
        //console.log("test in header model route");
        //return Ember.Object.create({
        return Ember.RSVP.hash({
            printers: What Goes Here?,
            otherObjects: More Stuff Here
        });
    },
});

I'm trying to follow the answer here https://stackoverflow.com/a/20523510/697827, but since I'm not accessing through Ember-Data I don't think this.store.find('printers') is going to get me what I need.

I'm missing something. Please help!

Community
  • 1
  • 1
Daniel E
  • 529
  • 1
  • 4
  • 18

1 Answers1

1

RSVP.hash expects an object with keys and promises as values. So I think that the following could work:

GradingX.HeaderRoute = Ember.Route.extend({
    model: function () {
        return Ember.RSVP.hash({
            printers: $.getJSON("http://localhost/printers"),
            otherObjects: $.getJSON("http://localhost/???")
        });
    },
});

In the referenced answer is used this.store.find, which also returns a promise, but it's resolved with a DS.RecordArray (an array like object provided by ember data). So what matters for RSVP.hash are promises.

Marcio Junior
  • 19,078
  • 4
  • 44
  • 47