How to force a view refresh without having it trigger automatically from an observable?

THX-1138 picture THX-1138 · Dec 16, 2011 · Viewed 129.5k times · Source

Note: this is mostly for debugging and understanding KnockoutJS.

Is there a way to explicitly request Knockout to refresh the view from (already bound) view model? I am looking for something like:

ko.refreshView();

I understand that this is not an intended use of Knockout, but I still want to know if there is a such method for debugging and learning purposes.

Answer

RP Niemeyer picture RP Niemeyer · Dec 16, 2011

You can't call something on the entire viewModel, but on an individual observable you can call myObservable.valueHasMutated() to notify subscribers that they should re-evaluate. This is generally not necessary in KO, as you mentioned.