Question

Model:

Blocks.NVD3Chart = Blocks.DSModel.extend({
    xAxis: DS.attr()
    ,series: DS.attr()
})

Blocks.NVD3Chart.FIXTURES = [
    {
        "id": "02c6486ac0a8017400348bcdb2029c63asdf"
        ,xAxis: [1,2]
        ,series: [
        {
            data: [10,20]
            ,name: "Employment"
        }
    ]
    }]

Route:

Blocks.LetsseeRoute = Ember.Route.extend({
    model: function() {
        return this.store.find('NVD3Chart')
    }
})

View:

Blocks.LetsseeView = Ember.View.extend({
    templateName: 'letssee',
    drawChart: function () {
        console.log(this.get("controller.content"))
        console.log(this.get("controller.model"))
    }.on("didInsertElement")
})

And I'm using the implicit controller declaration. Here is the results of the log statement results that are called on didInsertElement. (http://imgur.com/E74see7)

Now, the problem comes down to retrieving the content from the controller. Inside the controller content's length is 0. The model does exist though and it does have a content. But the data within the first element of content is undefined. However, the _data property is defined, and contains the data I need. I don't want to utilize the _data values because it is a pristine copy ember data stores and I don't want to muck with it. What is the proper way of setting and retrieving the content from the route inside the controller/view? Is there something I am not doing properly?

Was it helpful?

Solution

Workaround I did was using the content found within the model. And even though when logging object, data is undefined and all the data is stored inside _data for the model object, calling .get("data") on the object returns the expected results.

this.get("controller.model.content")[0].get("data")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top