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

后端 未结 9 1942
忘了有多久
忘了有多久 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:41

    Have you tried calling knockout's clean node method on your DOM element to dispose of the in memory bound objects?

    var element = $('#elementId')[0]; 
    ko.cleanNode(element);
    

    Then applying the knockout bindings again on just that element with your new view models would update your view binding.

提交回复
热议问题