我有以下html片段:
<tbody data-bind="foreach: ptData">
<tr id="Tr1">
<td><a data-bind="attr: {href: '/ProjectTrack/IssueGrid.aspx?IssueID='+ptId}">PT Launch</a></td>
<td nowrap="nowrap" data-bind="text: ptId">
</td>
<td nowrap="nowrap" data-bind="text: ptProject">
</td>
<td nowrap="nowrap" data-bind="text: ptTitle">
</td>
<td nowrap="nowrap" data-bind="text: ptPriority">
</td>
<td nowrap="nowrap" data-bind="text: ptType">
</td>
<td nowrap="nowrap" data-bind="text: ptStatus">
</td>
<td nowrap="nowrap" data-bind="text: ptUpdated">
</td>
<td nowrap="nowrap" data-bind="text: ptAssignedTo">
</td>
<td style="display: none" data-bind="text: ptUrl">
</td>
</tr>
</tbody>
我有以下带有动态内容的视图模型:
var viewModel = {
ptData: ko.observableArray([])
};
function DataResult(ptId, ptProject, ptTitle, ptPriority, ptType, ptStatus, ptUpdated, ptAssignedTo, ptDesc, ptUrl) {
this.ptId = ko.observable(ptId);
this.ptProject = ko.observable(ptProject);
this.ptTitle = ko.observable(ptTitle);
this.ptPriority = ko.observable(ptPriority);
this.ptType = ko.observable(ptType);
this.ptStatus = ko.observable(ptStatus);
this.ptUpdated = ko.observable(ptUpdated);
this.ptAssignedTo = ko.observable(ptAssignedTo);
this.ptDesc = ko.observable(ptDesc);
this.ptUrl = ko.observable(ptUrl);
}
我有一个 jQuery ajax 调用来返回填充在 DataResult 对象中的数据,并且每个 DataResult 对象都被推送到 viewModel.ptData。以下 knockout.js 命令似乎在 HTML 片段中不起作用:
"attr: {href: '/ProjectTrack/IssueGrid.aspx?IssueID='+ptId".
我到底做错了什么?