我想打開一個部分視圖作爲一個JQuery對話框,當我點擊一個鏈接打開另一個Jquery對話框時,這個對話框就已經打開了。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 1.6.2 v和jQuery UI的1.8.12
你問之前試過嗎?你只需調用'$('#otherDialog')。dialog('open')',新的對話框就會出現在第一個對話框上。 – 2011-12-27 17:02:59
我做了,沒有任何反應 – 2011-12-27 17:04:37
對我來說很好:http://jsfiddle.net/MZAtp/。向我們顯示您的代碼,我們可以嘗試提供幫助。 – 2011-12-27 17:09:37