1
我有一個模態窗口,可以動態填充。點擊按鈕後,它將在表中的每一行打開。這裏有一個例子:Javascript,X-Editable只更新第一個提交的數據,但不是第二個
<!-- The Modal -->
<div id="callModal" class="callModal">
<!-- Modal content -->
<div class="modalCall-content">
<div class="modalCall-header">
<span class="closeModal">×</span>
<h2 id="nameOfCalled">Modal Header</h2>
</div>
<div class="modalCall-body">
<p class="shortNoteOfLeadClass" id="shortNoteOfLead" style="font-size:25px;"></p>
<p>There will be statuses, notes and last call info...</p>
</div>
<div class="modalCall-footer">
<h3><button type="button" class="btn btn-danger">End Call</button></h3>
</div>
</div>
</div>
這是我如何填寫表格:
// Get the modal
var modal = document.getElementsByClassName('callModal')[0];
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("closeModal")[0];
// When the user clicks on the button, open the modal
function callThisTel(telID) {
var leadName = document.getElementById("leadName_"+telID).textContent;
var leadDescript = document.getElementById("leadDescript_"+telID).textContent;
var assignedTo = document.getElementById("leadAssignedTo_"+telID).getAttribute("data-title");
var currentProfile = document.getElementsByClassName("staff-profile")[0].getAttribute("alt");
document.getElementsByClassName("shortNoteOfLeadClass")[0].setAttribute("data-pk", telID);
document.getElementById("nameOfCalled").textContent = leadName;
document.getElementsByClassName("shortNoteOfLeadClass")[0].textContent = leadDescript;
modal.style.display = "block";
$.fn.editable.defaults.mode = 'inline';
$('.shortNoteOfLeadClass').editable({
url: '<?php echo base_url('changeData.php'); ?>',
pk: telID,
type: 'text',
title: 'Change description'
});
}
但問題是,每個模態打開時,它的工作好。所有的數據填寫沒有任何錯誤。所有的文本都像在表格中一樣。模式中的所有PK變化,當我編輯/保存文本時,它的效果很好。但是在我第二次提交表格後,它只會改變我第一次提交的第一個「PK」。但不是新的,每次打開模式都會更新。