【发布时间】:2017-02-02 02:50:12
【问题描述】:
HTML:
<div id="printCardModal">
<table class="table">
<thead>
<tr>
<th>Employee</th>
<th>Start Time</th>
<th>End Time</th>
<th>Start Time</th>
<th>End Time</th>
</tr>
</thead>
<tbody>
<!-- ko foreach: employees -->
<tr>
<td data-bind="text: name"></td>
<td><input class="input-medium"></td>
<td><input class="input-medium"></td>
<td><input class="input-medium"></td>
<td><input class="input-medium"></td>
</tr>
<!-- /ko -->
</tbody>
</table>
<button data-bind="click: printCard">
Print
</button>
</div>
和 JS:
self.printCard=function(){
$( "#printCardModal" ).dialog({
dialogClass: "no-close",
resizable: true,
maxHeight: 600,
width: 1000,
modal: true,
buttons: {
"Create PDF": function() {
...
},
Close: function() {
$(this).dialog( "close" );
}
}
});
};
我当然不会写所有东西。上面的 HTML 只是主要 HTML 的一部分。我的问题是 tad 的内容 首先出现在 HTML 主页面中,只有当对话框模式打开时,它才会从主页面获取它(thead 的内容)并呈现到对话框模式. 但是,对于仅出现在模态中的可观察数组员工的内容,一切都很好。 #printCardModal 中的所有内容仅在对话框模式打开时出现,我该怎么办?
【问题讨论】:
-
当您需要使用不是 Knockout 的东西来操作 DOM 时,您需要一个自定义绑定处理程序。见stackoverflow.com/a/8611892/392102
标签: html jquery-ui knockout.js