Knockout cleanNode()删除了jquery事件绑定? [英] Knockout cleanNode() removes jquery event bindings?

查看:80
本文介绍了Knockout cleanNode()删除了jquery事件绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Knockout的 cleanNode()函数似乎正在删除节点内元素的jQuery事件绑定。如何防止这种情况?

我在 cleanNode()上找不到太多文档。

Knockout's cleanNode() function seems to be removing jQuery's event bindings on elements inside the node. How can I prevent this?
There is not much documentation I could find on cleanNode() either.

推荐答案

处理此问题的最佳方法是将jQuery绑定代码与knockout绑定分开。通过这种方式,您可以简单地调用该函数来重做jQuery绑定。
不幸的是,现有代码的代码重构可能需要这样做。

The best way to handle this is to keep the jQuery bindings code separate from the knockout bindings. In this way, you can simply call the function to redo the jQuery bindings. Unfortunately, a code refactor of existing code might be required to do this.

这篇关于Knockout cleanNode()删除了jquery事件绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆