Knockout.js ViewModel 更改回调?
我正在尝试在 Knockout.js 应用程序中实现自动保存功能。
有没有办法在 ViewModel 发生变化时分配回调?
I'm trying to implement an auto-save feature in a Knockout.js app.
Is there a way to assign a callback for whenever a ViewModel changes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请访问 http://www 查看 Ryan Niemeyer 的聪明、肮脏的标志.knockmeout.net/2011/05/creating-smart-dirty-flag-in-knockoutjs.html
Take a look at Ryan Niemeyer's smart, dirty flag at http://www.knockmeout.net/2011/05/creating-smart-dirty-flag-in-knockoutjs.html
创建一个依赖于 ViewModel 中所有内容的 dependentObservable 很简单 - 我假设有人会发布一个比这个包含显示它的代码更好的答案。
(我更希望有一个内置的“任何更改”回调,但据我所知没有。)
It is straightforward to create a dependantObservable that depends on everything in your ViewModel - I assume someone will post an answer better than this one that contains code showing it.
(I would prefer if there was a built in "any change" callback, but as far as I can tell there is not.)