Reputation: 417
Clicking on .next takes me to the next page, but all current documents will still show up – plus the new ones. None is taken away. So if page 1 shows a list of 4 docs, page 2 will show a list of 8 docs. Only a reload will show the correct amount (4) of documents. Why? Thanks!
displayQty = 4;
Router
var subs = new SubsManager();
Router.route('/browse/:page', {
name: 'browse',
template: 'browse',
data: function() {
subs.subscribe('PixPage', this.params.page);
}
});
Publish
Meteor.publish('PixPage', function(page) {
cursor = (displayQty * page) - displayQty;
return MyPix.find({}, {sort: {uploadedAt: -1}, limit: displayQty, skip: cursor});
});
Template
Template.browse.events({
'click .next': function(event, template) {
var currentPage = Number(Router.current().params.page);
var nextPage = currentPage + 1;
Router.go('browse', {page: nextPage});
}
})
Upvotes: 0
Views: 42
Reputation: 444
Always be specific regarding what data to display on your model. Think of you're client as having a database that contains more data than you need to display, because often it does.
Use limit, order, etc in your mongo query to display only relevant data.
Upvotes: 1
Reputation: 3043
subs manager caches the data, try with normal subscription Meteor.subscribe('')
Upvotes: 2