I have a simple List view in MVC that renders some products. As soon as 1 product is selected I open a JQuery modal popup in this way:
我在MVC中有一个简单的List视图,可以呈现一些产品。一旦选择了1个产品,我就会以这种方式打开一个JQuery模式弹出窗口:
function showDetails(id) {
hostId = id;
$("#detailDialog").load('/Product/Details/' + hostId);
$("#detailDialog").dialog("open");
}
The modal popup correctly loads the partial view with the details. As soon as I press submit in the view, the view returns the result (ActionResult) in a brand new page completely white with only the content of the view. How I can keep everything inside the popup? I need to do that because if the form has some invalid characters, I want to reshow in the popup the view with the validation errors.
模态弹出窗口正确加载带有详细信息的局部视图。只要我在视图中按提交,视图就会在全新的页面中返回结果(ActionResult),只显示视图的内容。如何将所有内容保存在弹出窗口内?我需要这样做,因为如果表单有一些无效字符,我想在弹出窗口中重新显示验证错误。
1 个解决方案
#1
1
Your going to need to post more code. Like right now you just have the dialog box open. I don't see any of dialog buttons.So I am guessing your just put your own button that gets loaded from the ajax load?
您需要发布更多代码。就像现在你只需打开对话框。我没有看到任何对话框按钮。所以我猜你只是把你自己的按钮从ajax加载加载?
So maybe if we see that code as well it might help as you say submit. Does that mean you have a button that does a submit request? If so that will make a full post back.
所以,如果我们看到代码也可能有帮助,就像你说提交一样。这是否意味着您有一个提交请求的按钮?如果是这样,将发回完整的帖子。
You either have to cancel the submit request by like putting "return false" at the end of it or change the submit button it a regular button and hook it up with a $.post();
您必须取消提交请求,例如在其末尾添加“return false”或将提交按钮更改为常规按钮并将其与$ .post()挂钩;
This is just a simple example of blocking the submit call.
这只是阻止提交调用的一个简单示例。
http://jsbin.com/avebu/2
if you remove the return false it will load up the entire page again.
如果删除返回false,它将再次加载整个页面。
#1
1
Your going to need to post more code. Like right now you just have the dialog box open. I don't see any of dialog buttons.So I am guessing your just put your own button that gets loaded from the ajax load?
您需要发布更多代码。就像现在你只需打开对话框。我没有看到任何对话框按钮。所以我猜你只是把你自己的按钮从ajax加载加载?
So maybe if we see that code as well it might help as you say submit. Does that mean you have a button that does a submit request? If so that will make a full post back.
所以,如果我们看到代码也可能有帮助,就像你说提交一样。这是否意味着您有一个提交请求的按钮?如果是这样,将发回完整的帖子。
You either have to cancel the submit request by like putting "return false" at the end of it or change the submit button it a regular button and hook it up with a $.post();
您必须取消提交请求,例如在其末尾添加“return false”或将提交按钮更改为常规按钮并将其与$ .post()挂钩;
This is just a simple example of blocking the submit call.
这只是阻止提交调用的一个简单示例。
http://jsbin.com/avebu/2
if you remove the return false it will load up the entire page again.
如果删除返回false,它将再次加载整个页面。