Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete all items and perform a new query #47

Closed
joshuadeanhall opened this issue Jun 27, 2015 · 7 comments
Closed

Delete all items and perform a new query #47

joshuadeanhall opened this issue Jun 27, 2015 · 7 comments

Comments

@joshuadeanhall
Copy link

I have a list with a search feature. When a user performs a search I need to remove all items from the list and perform a new query to populate the list.

So far the best I have got is an action on the route that looks like

this.set('controller.model', this.infinityModel("items", {
id: params.Uid,
perPage: 25,
startingPage: 1,
filter: 'test'
}))

This deletes the items and does a new query but the scrolling fails. (Also I would prefer to be able to do this on the controller). I couldn't find any documentation on how to reset the list and wasn't sure the best place to ask how to perform this.

@hhff
Copy link
Collaborator

hhff commented Jun 28, 2015

Yeah I've had a couple questions about resetting the list. The way you're doing it is how I recommend doing it - but I'll have a play around with this in the coming week and maybe roll an official solution. Stay tuned!

@hhff
Copy link
Collaborator

hhff commented Jun 28, 2015

@joshuadeanhall - are you using ember data 1.13x by chance?

RE: controllers: You can do this from the controller also - but we recommend doing it from the route as controllers are set to be deprecated in ember 2.0+

@joshuadeanhall
Copy link
Author

@hhff I am using ember 1.13.4.

When doing what I posted above I get the following error after hitting the action that refreshes the model and going hitting the end of the first page (After the reload when it tries to load the next page it fails).

The result of a server query (on @model:item:) is immutable.
at ember$data$lib$system$record$arrays$record$array$$default.extend.replace (vendor.js:66936)
at EmberObject.default.extend.replaceContent (vendor.js:40774)
at EmberObject.default.extend._replace (vendor.js:40907)
at EmberObject.default.extend.pushObjects (vendor.js:40983)
at vendor.js:78403
at tryCatch (vendor.js:56001)
at invokeCallback (vendor.js:56013)
at publish (vendor.js:55984)
at vendor.js:36987
at Queue.invoke (vendor.js:11432)

My action looks like this

    actions: {
    doStuff: function() {
      var params = this.controllerParams;
      this.set('controller.model', this.infinityModel("item", {
        clientFilingUid: params.Uid,
        perPage: ENV.APP.pageSize,
        startingPage: 1,
        filter: 'test'
      }))
    }
}

And my model() looks like
model: function (params, transition) {

    this.controllerParams = params;

    var model =  this.infinityModel("item", {
        clientFilingUid: params.Uid,
        perPage: ENV.APP.pageSize,
        startingPage: 1
    });
  return model;
}

Didn't know about controllers in 2.0 thanks for the advice.

@hhff
Copy link
Collaborator

hhff commented Jun 29, 2015

gotcha. thanks for the info! traveling at the moment and won't have a chance to look into this for a couple weeks. Believe its related to #42

@hhff
Copy link
Collaborator

hhff commented Jun 29, 2015

FWIW, we don't support 1.13.x of ember or ember data yet, there's a PR up for that at the moment

@kellyselden
Copy link
Collaborator

Have you considered using a queryParam? They can rerun your model hook for you and flush out your results: http://www.foraker.com/blog/creating-a-better-search-experience-with-ember

@hhff
Copy link
Collaborator

hhff commented Aug 27, 2015

closing this for now - as I believe this is resolved

@hhff hhff closed this as completed Aug 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants