Reputation: 220
Dear all,
Template.tmp_detail_campaign_code_batch.events({
'click .ancProdCodePagination': function (e) {
Meteor.subscribe('ItemPage', Number*10,10)
}
});
Its definition:
Meteor.publish('ItemPage', function(skipItem, takeItem){
return Item.find({},{
skip : skipItem,
limit : takeItem
}); }
When I click .ancProdCodePagination, the amount of subscribed Items keep increasing by 10. For pagination, I'd like to make the amount stay at 10, but with different Items for each click.
What should I do?
Upvotes: 2
Views: 4025
Reputation: 8013
You just need to stop
the previous subscription first, which will involve storing the handle that it returns somewhere:
var itemSub;
Template.tmp_detail_campaign_code_batch.events({
'click .ancProdCodePagination': function (e) {
if (itemSub)
itemSub.stop();
itemSub = Meteor.subscribe('ItemPage', Number*10,10);
}
});
From the docs, the stop
method does this:
Cancel the subscription. This will typically result in the server directing the client to remove the subscription's data from the client's cache.
Upvotes: 5