我有两个引导程序模态,这是模态内的一个模态。 模式2包含搜索列表。 这意味着,有一个搜索框供用户输入名称。 还有一个表来显示检索到的列表。 我想在表格中放置一个选择按钮。 因此,当我单击选择按钮时,模态2关闭。 所选模式的数据只剩下modal1。 我的第一个问题是在modal2中如何提交搜索词并检索表中的结果列表。 我尝试了下面的代码,但它不断刷新页面,其中我重新打开了模态以查看结果。 搜索按钮有效,因为它显示了数据。 我想提交搜索词而不刷新我的页面。 同时,我的模态中的内容应该更新。
<div class="modal fade" id="modal1" role="dialog" >
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Modal 1</h4>
</div>
<div class="modal-body">
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#modal2">Open second modal</button>
<div class="modal-footer">
</div>
</div>
</div>
</div>
<div class="modal fade in" id="modal2" role="dialog" >
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modal2">Modal 2</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form" method="get"
<div Class="form-group">
<Label Class="control-label col-md-2">Name</Label>
<div Class="col-sm-4">
<input type="text" name="strName" Class="form-control">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" id="btnSearch" value="search" class="btn btn-default">Search</button>
</div>
</div>
</form>
<div class="panel-body">
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
<thead>
<tr>
<th class="col-md-1" style="text-align:center">ID</th>
<th class="col-md-8" style="text-align:center">Name</th>
</tr>
</thead>
<tbody>
@for Each Item In Model
@<tr>
<td class="col-md-8">@Html.DisplayFor(Function(modelItem) Item.name)</td>
</tr>
Next
</tbody>
</table>
</div>
</div>
<div class="modal-footer">
<Button type="button" Class="btn btn-primary" data-dismiss="modal">Close</Button>
</div>
</div>
</div>
</div>