Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

could the result of a server query be mutable? #370

Closed
ppcano opened this Issue · 5 comments

4 participants

Pepe Cano Paul Chavard Peter Wagenet John Emhoff
Pepe Cano

I am facing many times with this issue, which seems to be a common situation when client request to paginated/offset resources.

    var content = this.get('content');
    models = App.store.find(Yn.Model, {limit: 3, offset: 3, xxxxxx});
    models.addObserver('isLoaded', function() {
        if (!!content) {
           content.pushObjects(models);
        } else {
           this.set('content', models);
        }
    })

A solution/workaround is to create a mutable array as documented on this stackoverflow post.

I don't know if it could be possible/suitable to improve the result query to be mutable.

Paul Chavard

You should do pagination with an ArrayController not directly on an AdapterPopulatedRecordArray.
https://gist.github.com/1559628

Peter Wagenet wagenet closed this
Peter Wagenet
Owner

If @tchak's suggestion doesn't work for you, let us know.

John Emhoff

I'm sorry, I'm not sure what you mean with your suggestion? Likewise, I'm trying to append some objects to an ArrayController that was created with data from Ember Data and I get the same error when I call addObjects: https://gist.github.com/4083980

The linked stackoverflow post above gets around this by having a member variable shadow the "real" content attribute, which feels like it should be an unnecessary hack.

Peter Wagenet
Owner

@ppcano, JohnEmhoff the issue is that the results of a find is not a standard array. If you want to manipulate it as a standard array, you should use toArray() once the initial results are loaded.

John Emhoff

Thanks, that's a little cleaner.

Ben Konrath benkonrath referenced this issue in onepercentclub/onepercentclub-site
Merged

Properly add wallpost to top of list. #162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.