You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found and fixed a bug in your implementation of CollectionObservable._onObservableArrayChange.
Your code resets the source Backbone collection when you re-order any of filtered ObservableCollections (having the same source), and therefore it loses all filtered-out models:
There is a problem if you use knockout-sortable with dynamically filtered and sorted arrays. Here is an example:
panels = new Backbone.Collection([ { dock: 'left', order: 0 }, { dock: 'right', order: 1 }, ..... ]);
panelsLeft = kb.collectionObservable(panels, {
filters: function (panel) { return panel.get("dock") != "left"; },
sort_attribute: "order"
});
panelsRight = kb.collectionObservable(panels, {
filters: function (panel) { return panel.get("dock") != "right"; },
sort_attribute: "order"
});
<div data-bind="sortable: panelsLeft"> ... template
<div data-bind="sortable: panelsRight"> ... template
You sort the left panels, and all right panels disappear, and vice versa.
collectionObservable is listening to changes and updating the source collection, but it doesn't take filters into account.
I am trying to fix it, but not sure how yet.
The text was updated successfully, but these errors were encountered: