Reputation: 20730
I have an interesting problem:
My Meteor collection has a sort column. My Blaze template helper sorts the collection before rendering.
This collection draws a set of sortable rows, sorted with $('rowset').sortable();
.
I have an onStop
event that then reads the new child layout and does an update to the Meteor collection with new sort
fields.
The change then triggers the collection re-sort, and re-render of the template.
However, I found that Blaze, trying to be efficient, reads the collection sequence change, and instead of redrawing all of the rows, it re-orders them by doing a diff on the previous order.
Being unaware that jQuery already re-ordered the rows, the new resultant order is wrong until I entirely leave and re-enter that template.
The only solution I have found is to:
a. Empty the collection,
b. After redraw, re-populate the collection in the new order, forcing a full redraw and subsequent correct sequencing.
The problem with this is that the rows disappear and then reappear, giving a terrible presentation.
I'm looking for a better solution, perhaps something that tells Blaze not to try and redraw on update. Any ideas?
Upvotes: 3
Views: 212
Reputation: 133
If you are loading a collection from DB, you can disable the reactive behavior when fetching data:find({},{reactive: false})
Upvotes: 2