I'm working on a master detail view using Knockout.js. Basically, everything works fine, with one little drawback: Whenever the item that is currently shown in the detail view is changed, the master does not update itself accordingly.
Basically, I understand why this is:
ko.observableArray
and as such it only keeps track of inserting and removing items. It does not react on updated items.ko.observable
which is the base for the detail view.The question now is how to deal with this in an elegant and correct way?
I can currently think of two possible solutions:
ko.observable
. This way it will detect any changed made in the details view and update the UI accordingly.JSON.parse(JSON.stringify(...));
and replace()
the entry within the array with the cloned object. As now an object has been removed and inserted internally, the array detects the change and updates UI.The problem:
Any better ideas?
IMHO - I can't never know all performance issues. Your explained first solution is simple and do what you want. A possible other way is rebind contained tags to a ko.computed(...).