jQuery模态窗口显示MVC3局部视图 - 作品首次点击仅 [英] Jquery Modal Dialog displaying MVC3 partial view - works first click only

查看:169
本文介绍了jQuery模态窗口显示MVC3局部视图 - 作品首次点击仅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 公众的ActionResult MeanQ(INT ID)
{
    访问访问= db.Access.Find(ID);
    返回PartialView(_ MeanQPartial访问);
}

局部视图,多数民众赞成在上面code被渲染显示在模态对话框(jQuery的)...这显示在一个jQuery模态窗口的局部视图链接(的onclick)非常适用于第一次点击。有一次,我再次关闭该对话框,点击该链接后,局部视图如预期在一个弹出窗体不会打开。它打开在浏览器中新的一页。我怎样才能让弹出的模式对话框的链接工作每次都以同样的方式?

的Javascript code是低于(jQuery模态窗口):

 <脚本类型=文/ JavaScript的>
$(文件)。就绪(函数(){
    //初始化对话框
    $(#结果)对话框({宽度:400,可调整大小:真的,位置:中心,标题:访问信息,的AutoOpen:假的,
        按钮:{确定:函数(){$(本).dialog(亲密); }}
    });
});$(函数(){
    $('#模式')。点击(函数(){
        //将this.href的内容,然后把它变成一个对话框。        $('#结果')负载(this.href).dialog('开');
        返回false;
    });
});

HTML链接触发模式对话框:

  @ Html.ActionLink(弹出式,MeanQ,新{ID = item.AccID},{新的id =莫代尔})


解决方案

最近我也面临着,我想用这两个部分和全部剃刀视图slimier问题。我也跟着下面的文章来实现我的模态对话框。它工作得很好。

<一个href=\"http://www.matthidinger.com/archive/2011/02/22/Progressive-enhancement-tutorial-with-ASP-NET-MVC-3-and-jQuery.aspx\" rel=\"nofollow\">http://www.matthidinger.com/archive/2011/02/22/Progressive-enhancement-tutorial-with-ASP-NET-MVC-3-and-jQuery.aspx

 public ActionResult MeanQ(int id)
{            
    Access access= db.Access.Find(id);
    return PartialView("_MeanQPartial", access);
}

The partial view thats being rendered in the above code is displayed in a Dialog Modal (Jquery)...The link(onclick) that displays the partial view in a Jquery Modal Dialog works well for the first click. Once I close that dialog and click on the link again, the Partial View does not open as expected in a pop up form. It opens as a new page in the browser. How can I make the pop up modal dialog link work the same way every time?

Javascript code is below (Jquery Modal Dialog):

<script type="text/javascript">
$(document).ready(function () {
    //initialize the dialog
    $("#result").dialog({ width: 400, resizable: true, position: 'center', title: 'Access info', autoOpen: false,
        buttons: { "Ok": function () { $(this).dialog("close"); } }
    });
});

$(function () {
    $('#modal').click(function () {
        //load the content from this.href, then turn it into a dialog.

        $('#result').load(this.href).dialog('open');
        return false;
    });
});

HTML Link that triggers the modal dialog:

@Html.ActionLink("PopUp", "MeanQ", new { id = item.AccID }, new { id = "modal" })

解决方案

Recently I also faced a slimier problem where I wanted to use both partial and full razor view. I followed following article to implement my Modal Dialog. And it worked fine.

http://www.matthidinger.com/archive/2011/02/22/Progressive-enhancement-tutorial-with-ASP-NET-MVC-3-and-jQuery.aspx

这篇关于jQuery模态窗口显示MVC3局部视图 - 作品首次点击仅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆