Jquery对话框按钮调用带有参数的操作方法

Jquery对话框按钮调用带有参数的操作方法,jquery,Jquery,我需要关于jQuery对话框功能的帮助。各部分代码如下所示 下面是actionLink选择按钮的代码 Html.ActionLink("Select", "EditExistingReferral", "UnresolvedItems", new { unresolvedReferralId = item.Id }, new { @class = "selectReferral" }) 单击此“选择”按钮时,我希望显示一个对话框。下面是jQuery对话框的代码 $(function Displ

我需要关于jQuery对话框功能的帮助。各部分代码如下所示

下面是actionLink选择按钮的代码

Html.ActionLink("Select", "EditExistingReferral", "UnresolvedItems", new { unresolvedReferralId = item.Id }, new { @class = "selectReferral" })
单击此“选择”按钮时,我希望显示一个对话框。下面是jQuery对话框的代码

$(function DisplaySystemMessage() {
    $('.selectReferral').click(function (e) {
        e.preventDefault();
        $('#system-message').dialog({
            modal: true,
            width: 400,
            height: 'auto',
            buttons: {
                "Continue": function () {
                    var href = $('.selectReferral').attr('href');
                    //alert(href);

                    $(this).dialog('close');
                },
                "Cancel": function () {
                    $(this).dialog('close');
                }
            }
        });

        //if its referral - open dialog
        $('#system-message').dialog('open');
    });
});
单击“继续”对话框按钮时,我希望使用Approvariate参数调用以下操作方法:

[HttpGet]
public ActionResult EditExistingReferral(string unresolvedReferralId) {
    int existingReferralId = int.Parse(unresolvedReferralId);
        ....      
}
请确定在单击“选择”按钮时如何获取正确的参数,以便在单击“继续”对话框按钮时将其传递给EditExistingReferral操作方法


提前感谢。

如果要从操作方法返回新视图,请

$(location).attr('href', href);
我应该这样做

但是,由于您已经在单击链接以触发对话框,因此更优雅的解决方案是,如果单击“继续”按钮并仅执行,则只允许事件发生

e.preventDefault();
如果单击“取消”按钮

我要警告的是,上述解决方案将取决于RouteConfig的设置方式。如果您将路由配置为提取unsolvedReferralID,则它将起作用,例如

{controller}/{action}/{unresolvedReferralId}
目前的做法是:

var href=$('.selectReferral').attr('href')

将始终获取类的第一个实例
selectReferral
,它不会为您获取适当的ID值(单击第一个实例时除外)

相反,获取刚刚单击的链接的HREF并将其放入变量中(将以下内容放在
e.preventDefault()之后;

var destinationHref=$(this.attr(“href”)

然后你可以在Continue函数中使用这个变量

使用您的
警报试试看href/id值是否符合预期

希望有帮助