Hi, Bennie,

JavaScript and jQuery already provide a few different methods for
doing this in any context.  I'll outline the two most common methods:

Use a closure:

function openDialog(someValue) {
    $('#example').dialog({
        buttons: {
            Yes: function() {
                // do something with someValue
                $(this).dialog('close');
            },
            No: function() {
                $(this).dialog('close');
           }
        }
    });
}

Use .data():

$('#example').dialog({
    autoOpen: false,
    buttons: {
        Yes: function() {
            // do something with $(this).data('someKey')
            $(this).dialog('close');
        },
        No: function() {
            $(this).dialog('close');
       }
    }
});

$('#example').data('someKey', someValue).dialog('open');


Hope that helps.


On Feb 2, 6:10 pm, Bennie <timothy...@gmail.com> wrote:
> I need a way to do this today! So any help would be appreciated.
>
> I'm trying to do a confirm of a deletion on a list element, but I
> don't know how to pass info into dialog, and the examples I can find
> don't help much (they only pop up dialogs, they don't explain how to
> do anything in the callbacks).
>
> Here's what I have:
>
>                                 $("#example").dialog({
>                                         autoOpen:false,
>                                         modal: true,
>                                         buttons: {
>                                                 "No": function() {
>                                                         alert("no");
>                                                 },
>                                                 "Yes": function() {
>                                                         alert("yes");
>                                                 }
>                                         }
>                                 });
>
> It gets called something like this:
>
>                                 $("#portfolio ul li").click(function(e) {
>                                         $("#example").dialog("open");
>                                         //$(this).remove();    //I used to 
> just remove it, now I want to
> remove it only if confirmed by dialog
>                                 })
>
> Inside the "No" and "Yes" callbacks, how can I pass along the element
> I want to remove into the dialog? Worst case I'll store it off
> globally, but that seems really icky. Unfortunately, "this" and "$
> (this)" don't seem to have anything obviously interesting.
>
> How is this intended to be done in dialog()? Surely there must be some
> idea for how to get information into the callbacks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to jquery-ui@googlegroups.com
To unsubscribe from this group, send email to 
jquery-ui+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to