-
Notifications
You must be signed in to change notification settings - Fork 8
Description
In my app I have a view where the foreach binding is used with an observable array that's replaced when the user navigates somewhere else. Something like this:
<div data-bind="foreach: state.foo().entries, selection: {data: selection}">This construct works fine with foreach, but knockout.selection doesn't react to it when state.foo().entries evaluates to a different observableArray instance. It keeps working on the old observable array, leading to quite bizarre results.
As far as I can tell, supporting this would require knockout.selection to have an update handler that checks whether allBindingsAccessor().foreach.data has changed and updates its state accordingly. I've verified that update does fire under those circumstances.
This will probably require saving a lot of the state that's currently kept in variables inside init to be moved somewhere so it can be accessed from update.
I've added some failing tests here: https://github.com/papandreou/knockout.selection/tree/dynamic_foreach
Ping @sunesimonsen -- this doesn't appear to be addressed by https://github.com/sunesimonsen/knockout.selection/tree/refactoring yet. Is it something that you were planning to fix?