jquery-ui,使用dialog('open')并将变量传递给DIALOG [英] jquery-ui, Use dialog('open') and pass a variable to the DIALOG

查看:750
本文介绍了jquery-ui,使用dialog('open')并将变量传递给DIALOG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下JS:

$('#listeditdialog').dialog('open');

这将打开以下对话框:

$('#listeditdialog').dialog({
    autoOpen: false,
    resizable: false,
    position: ['center',150],
    width: 450,
    open: function(event, ui) {
        $("#listeditdialog").load("/projects/view/tasks/ajax/?listid=" + XXXX);
    },
    close: function(event, ui) {
        $("#listeditdialog").html('<p id="loading"> </p>');
    }
});

我的问题是,当我在另一个JS函数中使用对话框打开功能时,如何传递listID变量,该变量将导致单击甚至绑定触发对话框打开功能.

My Question is when I use the dialog open function in another JS function, how can I pass a listID variable which I would get fom the click even bind that fired the dialog open func.

谢谢!

推荐答案

如果我理解正确,那么您希望拥有在调用$('#listeditdialog').dialog('open')时可以访问的数据 打开事件触发时可用吗?

If I understand you right, you want to have data that you have access to when you call $('#listeditdialog').dialog('open') that's available when the open event fires?

类似的事情可能会有所帮助:

Something like this could help:

// where dialog is opened
$('#listeditdialog').data('listID', listIDVarOrSimilar); //assign the ID for later use
$('#listeditdialog').dialog('open')

// dialog definition
$('#listeditdialog').dialog({
    autoOpen: false,
    resizable: false,
    position: ['center',150],
    width: 450,
    open: function(event, ui) {
        var $led = $("#listeditdialog");
        $led.load("/projects/view/tasks/ajax/?listid=" + $led.data('listID'); //use the previously saved id
    },
    close: function(event, ui) {
        $("#listeditdialog").html('<p id="loading"> </p>');
    }
});`

http://api.jquery.com/data/

这篇关于jquery-ui,使用dialog('open')并将变量传递给DIALOG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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