【发布时间】:2016-07-30 20:13:55
【问题描述】:
$('#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.模型打开正确。 2. 无法访问 $('#modalSetDonationsProducts').on('show.bs.modal', 函数 (e) 并至少显示第一个警报。 3.我的模态调用来自另一个表的按钮,我只想通过 parent.find 方式设置输入 name="item"。
【问题讨论】:
-
您似乎错过了
;分号 (alert("dljasld")),因此它正在进一步执行您的 onShowOfModal 事件。 -
我认为没有效果,还是你的意思是另一个
-
如果你的 html 是这样的,你不应该转义 title 和 href。
-
点击显示模态 - 没有转义
-
@PoulBak 没有改变 :( ,模式打开但警报没有触发
标签: javascript c# jquery html twitter-bootstrap