how to detect what triggered the close event in jquery ui dialog

jquery-ui, modal-dialog

Solution

try this as discribed here: http://jqueryui.com/demos/dialog/#modal-confirmation

-- edit

copied from the link from above:

    var trigger = "";
    $("#dialog").dialog({
        bgiframe: true,
        resizable: false,
        height:140,
        modal: true,
        overlay: {
            backgroundColor: '#000',
            opacity: 0.5
        },
        buttons: {
            'Create': function() {
                // do your stuff
                trigger = "create";
                $(this).dialog('close');
            },
            Cancel: function() {
                $(this).dialog('close');
            }
        }
        close: function() {
            if (trigger == "create")
                // do something here
        }
    });

Problem

I have Create and Cancel buttons as part of a jquery-ui modal dialog. I want to do certain thing after closing the dialog only if the user clicks "Create". If they click "Cancel", or "X" or press Esc, I want to do something else. Is there a way to pass parameters to the close event handler or some other way to detect what caused the close?

Original source