且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Knockout.js中清除/删除可观察的绑定?

更新时间:2023-11-30 22:33:16

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);

然后使用新视图模型再次对该元素应用knockout绑定将更新视图绑定。

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