开发者

jquery-ui, Use dialog('open') and pass a variable to the DIALOG

I have the following JS:

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

Which opens the following dialog:

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

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.

Thanks!


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜