问题描述
我认为我有
@foreach (var item in Model)
{
<li>@Html.ActionLink("click me", "popup", "SomeData", new{id = item.ID}, new {@class = "PopUp"})</li>
}
然后我有一个看起来像这样的控制器;
I then have a controller that looks like this;
public ActionResult popup(Guid id)
{
var singelData = db.SomeRandomData.Find(id);
return PartialView(singelData);
}
还有一个看起来像这样的partialView;
And a partialView that looks like this;
<div>This a popup</div>
@Model.metadata1
到目前为止,当我单击链接时,我被重定向到partialView.
So far so good, when I click on a link I get redirected to a partialView.
现在我不舒服的部分是脚本部分,这是我的尝试;
Now to the part where I'm not comfortable, the script section, here is my attempt;
<script src="~/Scripts/jquery-ui-1.8.20.js"></script>
<script type="text/javascript">
$(function () {
$('.PopUp').click(function () {
$('<div/>').appendTo('body').dialog({
close: function (event, ui) {
dialog.remove();
},
modal: true
}).load(this.href, {});
return false;
});
});
</script>
但是它仍然只返回一个视图.我哪里出问题了?
But it still just returns a view. Where do i go wrong?
推荐答案
您应确保在显示的2个脚本之前 包含jQuery.另外,我建议您使用诸如FireBug之类的JavaScript调试工具,并查看控制台窗口,在该窗口中可能会看到脚本潜在的错误.
You should make sure that you have jQuery included before the 2 scripts you have shown. Also I would recommend you using a javascript debugging tool such as FireBug and looking at the console window where you might see potential errors with your scripts.
这篇关于将PartialView显示为弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!