敲门.js可以等到onClick才绑定吗? [英] Can knockout.js wait to bind until an onClick?
问题描述
这是来自此处的后续问题:从数组中获取可观测值
This is a follow-up question from here: Get observable from array
我现在从列表中得到一个可观察对象,并将其传递给模态进行编辑,如下所示:
I now have an observable from a list, and I pass it to a modal for editing like this:
var report = currentViewModel.getReport(reportId);
ko.applyBindings(report,$("#"+targetDiv)[0]);
(targetDiv是我刚刚通过ajax加载的模式)
(targetDiv is the modal that I just loaded via ajax)
现在将显示模式,当我编辑报告名称时,一旦失去焦点,该名称就会在原始列表中更改.我开始摆脱淘汰赛的陷阱,这正是我所期望的行为.
Now the modal shows up, and when I edit the report name, as soon as i loose focus, the name is changed in the original list. Im starting to get the hang of this knockout, and that is exactly the behavior that I expect.
我的问题是,我如何才能单击保存"就不这样做?模态上有一个取消"按钮,我希望所有更改都可以等到我单击保存".我已经在文档中看到可以在按键上执行此操作,但是我希望在onclick上执行此操作.
My question is, how do I get it to not do that until I click save? There is a cancel button on the modal and I would like for any changes to wait until I click save. I have seen in the documentation that I can do this on a keypress, but I want it on an onclick.
无论做什么,我都会做什么?
Anyway to do what I am after?
推荐答案
看看 查看全文