Sorry for my english.
So i have really weird problems with fetching metedata. My app display a list of bookmarks. I have setup an infinite scrolling system. It work perfectly. To setup this infinite scroll i have an action in my controller which load more bookmarks:
loadMore: function() {
var self = this;
var meta = this.store.metadataFor('bookmark');
if(meta.nextPage != null) {
self.set('isLoadingMore', true);
self.store.find('bookmark', {page: meta.nextPage})
.then(function(bookmarks) {
self.set('isLoadingMore', false);
}).catch(function(err) {
self.set('isLoadingMore', false);
});
}
else {
self.set('isLoadingMore', false);
}
}
So like that this function work perfectly. If I scroll it load the next page of bookmarks. This is the js console:
XHR finished loading: GET "http://localhost:8000/api/bookmarks?page=2".
jquery.js:8625 XHR finished loading: GET "http://localhost:8000/api/bookmarks?page=2".
jquery.js:8625 XHR finished loading: GET "http://localhost:8000/api/bookmarks?page=3".
jquery.js:8625 XHR finished loading: GET "http://localhost:8000/api/bookmarks?page=4".
jquery.js:8625 XHR finished loading: GET "http://localhost:8000/api/bookmarks?page=4".
jquery.js:8625 XHR finished loading: GET "http://localhost:8000/api/bookmarks?page=5".
But what i would like to do is to use these meteData in my template. So i had created a computed property in my controller:
metaData: Ember.computed('model.isFulffiled', function() {
return this.store.metadataFor('bookmark')
}),
Since i have done that I can access metadata in my template but the metada seems not been updated when the loadMore function is called. So the loadMore fonction allways load the next page given in the metadata of the initial request.
XHR finished loading: GET "http://localhost:8000/api/bookmarks?page=2".
jquery.js:8625 XHR finished loading: GET "http://localhost:8000/api/bookmarks?page=2".
jquery.js:8625 XHR finished loading: GET "http://localhost:8000/api/bookmarks?page=2".
jquery.js:8625 XHR finished loading: GET "http://localhost:8000/api/bookmarks?page=2".
jquery.js:8625 XHR finished loading: GET "http://localhost:8000/api/bookmarks?page=2".
jquery.js:8625 XHR finished loading: GET "http://localhost:8000/api/bookmarks?page=2".
jquery.js:8625 XHR finished loading: GET "http://localhost:8000/api/bookmarks?page=2".
I also posted the question on discuss.emberjs.com
Aucun commentaire:
Enregistrer un commentaire