How to clear/remove observable bindings in Knockout.js?

后端 未结 9 1931
忘了有多久
忘了有多久 2020-11-29 16:40

I\'m building functionality onto a webpage which the user can perform multiple times. Through the user\'s action, an object/model is created and applied to HTML using ko.app

9条回答
  •  一整个雨季
    2020-11-29 17:19

    I have found that if the view model contains many div bindings the best way to clear the ko.applyBindings(new someModelView); is to use: ko.cleanNode($("body")[0]); This allows you to call a new ko.applyBindings(new someModelView2); dynamically without the worry of the previous view model still being binded.

提交回复
热议问题