$('#modalSetDonationsProducts').on('show.bs.modal', function (e) {
alert("dljasld");
rowNumber = 1;
$('#tblEmployees tbody tr').remove("tr:gt(0)");
alert("enterd");
var itemname = $(this).parent().parent().find(rowData["ItemName"]).val()
alert(itemname);
$(e.currentTarget).find('input[name="item"]').val(itemName);
$(e.currentTarget).find('input[name="description"]').val(itemName);
$(e.currentTarget).find('input[name="item"]').enabled = false;
});
我有这个功能 和模态
<div class="modal modal-flex " id="modalSetDonationsProducts">
<div class="modal-dialog" style="min-width: 900px; max-width:1000px;width:auto">
<div class="modal-content">
<div class="modal-header" style="width:100%;">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span> <span class="sr-only">Close</span></button>
<h4 class="modal-title"> <%= GetLocalResourceObject("addnewitem")%></h4>
</div>
<div class="modal-body">
<p><%= GetLocalResourceObject("addnewitem")%></p>
<div class="table-responsive">
<table class="table" id="tblEmployees">
<thead>
<tr>
<th>#</th>
<th></th>
</tr>
</thead>
<tbody>
<tr id="rowID1">
<td>1</td>
<td>
<input type="text" style="min-width:230px" readonly="readonly" name="item" value="" /></td> </tr>
</tbody>
</table>
</div> </div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"></button>
<button type="button" onclick="SaveProducts();" class="btn btn-green ladda-button">
</button>
</div>
</div>
</div>
</div>
我通过此
调用模态<a data-toggle=\"modal\" href=\"#modalSetDonationsProducts\" class=\"btn btn-green\" name=\"btnSplit\">add</a>
已经做的是:
1. model open Correctly . 2. it can't access the $('#modalSetDonationsProducts').on('show.bs.modal', function (e) and show the first alert at least . 3. my modal call by button from another table and I just want to set the input name="item" by parent.find way.
答案 0 :(得分:0)
工作小提琴:https://jsfiddle.net/3rfb4vny/
我猜您的目标元素出错了,我已经尝试过您的HTML和JS事件
$('#modalSetDonationsProducts').on('show.bs.modal', function (e) {
alert("displaying");
});