我有一个弹出的模态窗口,并在表格中显示供应商列表。每行都有一个“选择”按钮,用于从该行中选择数据,然后使用TD的值更新父页面上的某些表单输入字段。
在我首先使用数据表搜索或列排序之前,这样可以正常工作 如果我搜索或排序此表然后使用选择按钮,则不会分配任何数据。
同样,这个工作正常,只有在我使用内置数据表首先进行搜索/排序时才会中断。
$(document).ready(function () {
$(".select-vendor").click(function () {
var $row = $(this).closest("tr"); // Find the row
var $tds = $row.find("td");
console.log($row);
$.each($tds, function () {
document.forms["myForm"]["vendNameAddr"].value = $row.find('#vendNameAddrSearch').val();
document.forms["myForm"]["vendPhone"].value = $row.find('#vendPhoneSearch').val();
document.forms["myForm"]["vendEmail"].value = $row.find('#vendEmailSearch').val();
});
});
});
echo '<tr><td><input type="hidden" name="vendNameAddrSearch" id="vendNameAddrSearch" value="' . $vendorinfo . '"><input type="hidden" name="vendPhoneSearch" id="vendPhoneSearch" value="' . $res->phonenumber . '"><input type="hidden" name="vendEmailSearch" id="vendEmailSearch" value="' . $res->emailaddress . '"><button type="button" class="select-vendor" onclick="document.getElementById(\'vendorModal\').style.display=\'none\'">Select</button></td><td>' . $res->vendorname . '</td><td>' . $res->address1 . '</td><td>' . $res->address2 . '</td><td>' . $res->city . '</td><td>' . $res->state . '</td><td>' . $res->zip . '</td><td>' . $res->country . '</td></tr>';
答案 0 :(得分:0)
您可能有重复的ID。将所有ID更改为类并使用您开始的相对地址
plot3d(1,2,3, xlab="x", ylab="y", zlab="z", xlim=c(-4,4), ylim=c(-4,4), zlim=c(-4,4))
abclines3d(x = matrix(0, ncol=3), a = diag(3), col="black", lwd=3)
$(".select-vendor").on("click", function() {
$('#vendorModal').hide();
var $row = $(this).closest("tr"); // Find the row
$row.find(".vendNameAddr").val($row.find('.vendNameAddrSearch').val());
$row.find(".vendPhone").val($row.find('.vendPhoneSearch').val());
$row.find(".vendEmail").val($row.find('.vendEmailSearch').val());
});
答案 1 :(得分:0)
弄明白了这个问题。一旦我用onclick方法包装:
“fnDrawCallback”:function(oSettings){}
它现在可以在每次重绘后获取新的行数据。