I'm completely missing a hint that would describe how to handle the case when user adds new data into currently paginated data set. My case would be:
1) The page displays list of paginated records
2) User creates & saves new record
3) The record is immediately visible in the list of paginated records (assuming that it should be displayed given it's position in paginated data)
// controller.js
export default Controller.extend({
actions: {
createNewPost() {
// Note that this by itself won't make the post appear in paginated list of posts
let newPost = this.store.createRecord('post');
// Not even saving the data server side will make it appear on user's screen
return newPost.save().then(() => {
// This will force the ember-cli-pagination to re-fetch current page
this.get('model').setOtherParam('nameOrValueOfThisPropertyDoesNotReallyMatter', true);
});
}
}
});
{{! template.hbs }}
<button {{action "createNewPost"}}>Click me to create new post</button>
<ul>
{{#each model as |post|}}
<li>{{post.id}}</li>
{{/each}}
</ul>
Not: I'm writing that from the top of my head. Might not 100% compile.
Hope this might help somebody. Also if this snippet is correct, it would be nice to have it as part of the documentation.
I'm completely missing a hint that would describe how to handle the case when user adds new data into currently paginated data set. My case would be:
1) The page displays list of paginated records 2) User creates & saves new record 3) The record is immediately visible in the list of paginated records (assuming that it should be displayed given it's position in paginated data)
I think I found a nice solution which is unfortunately not documented anywhere:
Not: I'm writing that from the top of my head. Might not 100% compile.
Hope this might help somebody. Also if this snippet is correct, it would be nice to have it as part of the documentation.