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'
試圖這樣:
我擴展了我的答案, –
相關問題