我試圖在引導模型中加載局部視圖。因爲我在父頁面中有一個現有的表單,而在部分視圖中有另一個表單。我不能決定把這些表格放在一個頁面上,因爲那樣會有一個表格。Bootstrap-modal:在模態體中顯示的局部視圖
下面是我在父頁面複選框,選中時會顯示模式對話框:
<input type="checkbox" name="inputNewBornKMC" value="inputNewBornKMC" id="inputNewBornKMCCheckbox"> New Born
下面是父頁面模態對話框:
<div Class="modal fade" id="inputNewBornKMC" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close modal-close-btn" data-dismiss="modal">×</button>
<h4 class="modal-title">Search Newborn's Mother</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
@*<button type="button" class="btn btn-default" id="AddGP">Save changes</button>*@
</div>
</div> <!-- Modal content-->
</div>
</div> <!-- Modal -->
在JavaScript,我把下面的代碼加載模態對話框:
$('#inputNewBornKMCCheckbox').on('change', function (e) {
var _this = $(this);
// if checked
if (_this.is(':checked')) {
$('#inputNewBornKMC').modal({
keyboard: false,
remote: '/controller/AddPartialRegistration'
}).show();
$('#inputNewBornKMCCheckbox').on('click', '.modal-link', function (e) {
e.preventDefault();
$(this).attr('data-target', '#inputNewBornKMC');
$(this).attr('data-toggle', 'modal');
});
}
這將調用一個actio n的控制器,顯示局部視圖:
public ActionResult AddPartialRegistration()
{
return PartialView("_PartialRegistration");
}
在_PartialRegistration頁:
<div class="modal-body">
<form class="form-horizontal" id="frmSearchMother" role="form" >
Mother's MRN
<input type="text" class="form-control input-sm" id="popupMotherMRN" name="popupMotherMRN" />
IC/ID No
<input type="text" class="form-control input-sm" id="popupICNo" name="popupICNo" />
Mother's Name
<input type="text" class="form-control input-sm" id="popupMotherName" name="popupMotherName" />
<button type="button" class="btn btn-default" id="SearchMother" >Search</button>
</form>
<br />
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="LoadMotherDetailsTable">
<thead>
<tr>
<th>No.</th>
<th>Mother's MRN</th>
<th>Mother's IC No</th>
<th>Mother's Name</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
我已經試過在人申請部分景色多種方式,但都沒有奏效。我不確定如何將部分視圖插入到模態對話框的模態體中。該對話框可以在選中複選框時顯示,但我不確定如何在模態體中加載局部視圖。
任何幫助將不勝感激。
反正感謝您的好意幫助:)我不太明白什麼是詠歎調,labelledby的功能?是不是重要? – Nurul
如果您希望視覺殘疾人士使用屏幕閱讀器並知道您的網頁正在發生什麼,這很重要 – JDro04