meteor-pages
meteor-pages copied to clipboard
Displayed items do not update reliably when client filters changed
Since upgrading Meteor from 1.2 to 1.6, my client filters are not working reliably.
When I change the filters, often the displayed list of items does not change.
If I run the following in the browser console then it updates correctly:
MyPaginationObject.reload()
However if I run reload() in the code, it only works if I leave about 1 second delay:
MyPaginationObject.set({
filters: Meteor.my_functions.set_filter({"number_of_things":{"$lt":9,"$gt":0}})
});
setTimeout(function(){
MyPaginationObject.reload();
}, 1000);
Running the reload() immediately doesn't work.
I have four different pagination objects that draw from the same collection, so I am already using requestPage(1) to work around a known issue with more than about 2 paginations (#208);
Template.my_page.onRendered(function() {
MyPaginationObject.requestPage(1);
});
I don't know if this is a related issue or not.
Has anybody had a similar problem and know of a solution? I'm assuming that my setup must be OK otherwise the filters wouldn't work at all.
Here's how the objects are defined:
this.MyPaginationObject = new Meteor.Pagination(Patterns, {
itemTemplate: "pattern_thumbnail",
templateName: "new_patterns",
perPage: 12,
availableSettings: {
filters: true,
sort: true
},
auth: function(skip, sub){
var userSettings = this.userSettings[sub._session.id] || {};
var userFilters = userSettings.filters || {};
var _filters = _.extend({
$or: [
{ private: {$ne: true} },
{ created_by: sub.userId }
]
}, userFilters);
var _options = {
limit: 12,
sort: { created_at: -1},
skip: skip
}
return [_filters, _options];
},
filters: {}
});
Thanks!