我在局部視圖中使用了引導模式。在我的索引視圖中,我單擊一個按鈕以在當前頁面上顯示部分視圖模式。 Jquery驗證設置爲在Bootstrap工具提示中顯示驗證錯誤。這些工具提示在所有頁面上顯示出色,但在渲染的局部視圖上顯示。引導工具提示在Ajax渲染部分視圖中不準確
我試過設置工具提示的z-index大於模式,但這不起作用。
管窺
@model Phase_3.ViewModels.UserCreateViewModel
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>New User</h3>
</div>
@using (Html.BeginForm("Create", "User", FormMethod.Post, new { @class = "remove-margin" }))
{
<div class="modal-body">
@Html.Label("First Name", new { @class = "inline" }) @Html.ValidationMessageFor(x => x.User.FirstName)
@Html.TextBoxFor(x => x.User.FirstName, new { @class = "modal-input input-validation-error" })
<br />
@Html.Label("Last Name")
@Html.TextBoxFor(x => x.User.LastName, new { @class = "modal-input" })
<br />
@Html.Label("Email")
@Html.TextBoxFor(x => x.User.Email, new { @class = "modal-input" })
<br />
@* REMOVE WHEN RANDOM SALT METHOD IS COMPLETED*@
@Html.Label("Salt")
@Html.TextBoxFor(x => x.User.Salt, new { @class = "modal-input" })
<br />
@Html.Label("Password")
@Html.TextBoxFor(x => x.User.Password, new { @class = "modal-input" })
<br />
@Html.Label("Role")
@Html.DropDownListFor(x => x.User.RoleId, new SelectList(Model.Roles, "Id", "Title"), new { @class = "row-fluid" })
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a>
<input type="submit" value="Create" class="btn btn-primary" />
</div>
@Scripts.Render("~/bundles/jqueryval")
}
索引視圖
@model IEnumerable<Phase_3.Models.User>
<script src="/Content/custom/js/display.modal.js"></script>
<div class="row-fluid spacer">
<div id="modal-container" class="modal hide fade" data-url='@Url.Action("Create")'>
<div id="modal-inner"></div>
</div>
<input type="button" id="display-modal" value="New User" class="btn btn-primary" />
</div>
@* Display users in data table *@
<div class="row-fluid">
<table class="table table-condensed table-hover">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Role</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(x => item.FirstName)</td>
<td>@Html.DisplayFor(x => item.LastName)</td>
<td>@Html.DisplayFor(x => item.Email)</td>
<td>@Html.DisplayFor(x => item.Role.Title)</td>
</tr>
}
</table>
</div>
顯示錯誤在工具提示
$.validator.setDefaults({
showErrors: function (errorMap, errorList) {
this.defaultShowErrors();
// destroy tooltips on valid elements
$("." + this.settings.validClass)
.tooltip("destroy");
// add/update tooltips
for (var i = 0; i < errorList.length; i++) {
var error = errorList[i];
$("#" + error.element.id)
.tooltip({ trigger: "focus" })
.attr("data-original-title", error.message)
}
}
});
您是否找到解決方案? – Stnfordly 2018-03-09 07:52:45