Comments (8)
The response needs to look like this:
{
items: [
{id: 1, name: 'Test'},
{id: 2, name: 'Test 2'}
],
meta: {
total_pages: 3
}
}
from ember-infinity.
Thank's for reply, works great now :)
from ember-infinity.
@szsoppa did you find a good solution for including the pages data in the JSON response under meta? I'm using headers now too, and can't find much on the backend with kaminari or grape on how to structure that properly.
from ember-infinity.
I used https://github.com/monterail/grape-kaminari gem to return all of the data required by ember-infinity. You can see in documentation that it's pretty simple to use.
from ember-infinity.
Thanks @szsoppa - I'm still not seeing where in grape-kaminari to tell it to include the total_pages in meta as part of the json response.. Is it conflicting with active_model_serializers perhaps?
from ember-infinity.
It may have a problem with active_model_serializers
. As you can see here https://github.com/monterail/grape-kaminari/blob/master/lib/grape/kaminari.rb#L11 it should include this header out of the box. I used grape-entity
gem to serialize data and it worked great.
from ember-infinity.
Found this https://github.com/ruby-grape/grape-active_model_serializers#custom-metadata to modify the Rails side, or this http://codeandtechno.com/posts/metadata-via-response-headers-in-emberjs/ to modify the Ember side. For anyone who might need it..
from ember-infinity.
Be aware that the default is "total_pages" with an underscore and you might be returning dasherized attribute names.
Also, the latest ASM includes links metadata by default, more here on that.
I had this issue and you can read more about it here.
My controller renders like this:
render json: @employees, meta: { total: (Employee.count / params[:per_page].to_f).ceil }
from ember-infinity.
Related Issues (20)
- infinity-loader needs to unhide on model change HOT 7
- model.canLoadMore not updating HOT 6
- infinityLoader renders JSON response data twice HOT 4
- isVisible is deprecated in 3.15
- 2.1.0 throws an EEXIST: file already exists on app build HOT 8
- Is it possible to use this component with a horizontal list? HOT 6
- Ember Infinity not working with latest Ember Data 3.17.0 & 3.16.0 HOT 9
- Possible issue with ember-source 3.16.2 HOT 6
- Not working in "ember-cli": "~3.4.4"? HOT 2
- Could not find plugin "proposal-class-properties". Ensure there is an entry in ./available-plugins.js for it.
- Demo link goes to 404. HOT 1
- Non-blocking model hook breaks `reachedInfinity`
- Problem with ember-in-viewport HOT 5
- Update doc examples with ES6 Classes
- devDependencies and dependencies are out of date HOT 2
- Issue with loadPrevious and scrollable HOT 2
- Will the project be supported for ember 4? HOT 2
- Error: Could not find module `@ember/polyfills` imported from `ember-in-viewport/initializers/viewport-config`
- Caching unchanged content ExtendedInfinityModel
- Side effects due to transfer ownership
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-infinity.