将变量传递到JQuery UI对话框 [英] Pass a variable to JQuery UI dialog

查看:66
本文介绍了将变量传递到JQuery UI对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP删除记录.我想使用JQuery UI对话框来确认操作,但是我不知道如何将变量(我的RecordID)传递给重定向URL函数,或允许URL访问window.location.href.

I am deleting a record using PHP. I want to use a JQuery UI dialog to confirm the action, but I dont know how to pass a variable (my RecordID) to the redirect URL function, or allow the URL to access window.location.href.

$("#confirm" ).dialog({
resizable: false,
autoOpen: false,
modal: true,
buttons: {
    'OK': function() {
            window.location.href = 'url and myvar??';
        $( this ).dialog( "close" );
        },
    'Cancel': function() {
        $( this ).dialog( "close" );
        }
    }
});


$("#delete").click(function() {
    $("#confirm").dialog( "open" ).html ( "Are U Sure?" );
    return false;
});

HTML

<a href='index.php?recordid=$row[recordid]' id='delete'>DELETE</a>

有什么好方法吗?

推荐答案

您可以尝试使用.data()方法为您存储数据.看看这个答案 将数据传递到jQuery UI对话框

You can try using the .data() method to store data for you. Take a look at this answer Passing data to a jQuery UI Dialog

例如,要传递变量,您可以在打开对话框之前使用数据功能将其存储

For example to pass a variable, you can store it using the data function, before opening the dialog

$("#dialog_div")
.data('param_1', 'whateverdata')
.dialog("open");

然后您可以通过以下方式将其取回:

Then you can get this back by:

var my_data = $("#dialog_div").data('param_1')

这篇关于将变量传递到JQuery UI对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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