我在页面上使用knockout.js视图模型,一切正常,除了我设置为jquery对话框的div中的单击绑定
这是div
<div id="CancelModal" title="Cancel">
Changes to the definition have been detected. Do you want to exit and discard the changes?"
<div style="position: absolute; bottom: 8px; right: 8px; text-align: right">
<input type="button" value="Yes" data-bind="click: cancelConfirm" />
<input type="button" value="No" data-bind="click: cancelDeny" />
</div>
</div>
那我的jquery
$("#CancelModal").dialog({
modal: true,
autoOpen: false,
width: 400,
minHeight: 150,
maxHeight: 150,
position: "center",
resizable: false
});
然后在我的viewmodel中
...
cancelConfirm() {
alert("confirm");
}
cancelDeny() {
alert("deny");
}
绑定已设置但同样它们不适用于此对话框中的元素 . 如果我删除jquery对话框代码,它的工作原理 . 我在这里需要做什么?
2 回答
试试这个http://jsfiddle.net/76EEt/1/
HTML
JS
你需要改变它等于一个函数