我想打开一个部分视图作为JQuery对话框,当我点击一个链接打开另一个已经打开的Jquery对话框时。
我能这样做吗?如果有可能,我该如何实现?
编辑1:
第一个视图
@model AuctionWebProject.Areas.Admin.Models.CategoryModel
@{
ViewBag.Title = "Edit Category";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<!DOCTYPE html>
<html>
<head>
<title>EditCategory</title>
</head>
<body>
<script src="@Url.Content("~/Scripts/jquery-1.6.2.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.16.min.js")" type="text/javascript"></script>
<script type="text/javascript">
function ShowXsdEditor() {
$("#xsdEditor").dialog("open");
}
</script>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<legend>CategoryModel</legend>
@Html.HiddenFor(model => model.Id)
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Date)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Date)
@Html.ValidationMessageFor(model => model.Date)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Xsd)
</div>
<div class="editor-field">
@Html.TextAreaFor(model => model.Xsd, new { disabled = "disabled" })
@Html.ValidationMessageFor(model => model.Xsd)
<a href="javascript:void(0)" onclick="ShowXsdEditor();">Xsd Editor</a>
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@Html.Partial("XsdEditor", Model)
</body>
</html>
第二种观点
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"> </script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<div id="xsdEditor" style="display: none;">
<a href="javascript:void(0)" onclick="ShowDialog();">Add new element</a>
<div id="elementList">
</div>
</div>
@Html.Partial("AddXSElement", new AuctionWebProject.Areas.Admin.Models.XSElementModel())
<script type="text/javascript">
$(document).ready(function () {
$("#xsdEditor").dialog({
autoOpen: false, width: 400, height: 330, modal: true, title:'XSD Editor'
});
});
function ShowDialog() {
debugger;
$("#addXSElement").dialog("open");
}
</script>
我使用JQuery v 1.6.2和Jquery Ui 1.8.12
答案 0 :(得分:3)
根据我创建的the fiddle,它会显示没问题。
答案 1 :(得分:0)
发现问题,似乎文档准备好的JQuery函数没有按预期工作。 重新排序对话框java脚本后,问题就消失了。