Jquery Modal Dialog displaying MVC3 partial view - works first click only

我们两清 提交于 2019-12-04 10:23:39

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

Without knowing your JavaScript, my guess is you are somehow replacing the <a/> element when loading the PartialView since you mention the <a/> does the default action after loading the modal.

e.g.

$("#someA").click(function(){
  //loads the modal and replaces #someA
});

Try using .live():

$("#someA").live("click", function(){
  //loads the modal and replaces #someA, but still works since you used live()
});

Even better if the element has a common parent, you can use .delegate()

$("#someParentOfA").delegate("#someA", "click", function(){

});

Are you using MVC3? Instead of returning an "ActionResult" it might help if you return a "PartialViewResult".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!