0
我无法在此特定页面上使用$ root访问方法。此代码适用于我的其他页面,但我不明白。我每页有一个viewmodel。它无法找到removeAttachment。敲除js根绑定
淘汰赛3.4.0.js:72遗漏的类型错误:无法处理绑定 “点击:函数(){$返回data.bind.removeAttachment($的数据,事件,$指数)}” 消息:无法读取未定义
var model = function AppViewModel(){
self.removeAttachment = function(data, event, attachmentClicked){
fileNameToDelete = attachmentClicked;
$("deleteText").append(" " + attachmentClicked + "?");
$('#delete-confirm').modal('show');
};
};
var app = new model();
ko.applyBindings(app, document.getElementById("panel"));
<div id="panel">
<tbody class="types">
<!-- ko foreach: multiFileData().fileArray -->
<tr>
<td><span class="attachName" data-bind="text:name"></span></td>
<td><span class="attachName" data-bind="$parent.sizeInMB: size"></span></td>
<td id="remove" class="glyphicon glyphicon-trash" data-toggle="modal" data-target="delete-confirm"
data-bind="click:$root.bind.removeAttachment($data, event, $index)"> </td>
</tr>
<!-- /ko -->
</tbody>
</div>
财产 'removeAttachment'
试图这样:
我扩展了我的答案, –
相关问题