简体   繁体   English

在Knockout.js中选中Checkbox时,如何更新视图模型及其依赖项?

[英]How to update view model and its dependencies when Checkbox selected in Knockout.js?

Currently I have a very large of data model that is presented to the user with multiple options and events. 目前,我有一个非常大的数据模型,它通过多个选项和事件呈现给用户。

  1. List item as checkboxes 列出项目作为复选框
  2. Update the object's datetime when checked 选中时更新对象的日期时间
  3. Add checked item data to table array 将选中的项目数据添加到表数组
  4. Two options to deselect items: remove button on table or uncheck input 取消选择项目的两个选项:删除表格上的按钮或取消选中输入
  5. Post update to server when item is selected or deselected 当选择或取消选择项目时,将更新发布到服务器

I have been unable to create the correct knockoutjs script to make all events possible. 我一直无法创建正确的基因敲除脚本来使所有事件成为可能。 I definitely need help. 我绝对需要帮助。

Here is an example: http://jsfiddle.net/likwidmack/BxZGr/10/ 这是一个示例: http : //jsfiddle.net/likwidmack/BxZGr/10/

I have refactored your code here: 我在这里重构了您的代码:

http://jsfiddle.net/SKnMg/3/ http://jsfiddle.net/SKnMg/3/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM