Dynamically display buttons in dialog

Dynamically display buttons in dialog

Hello,

I would like to use the same dialog function to display alerts and confirm dialogs. Would I be able to have an if statement in the dialog code so I can display different buttons depending upon what parameters were passed into the function?

Something like:

  1.     var alerter = function (passit, confirmationBox) {

            $("#dialog-default > p").text(String(passit));

            $("#dialog-default").dialog({
                open: function () {
                    $(".ui-state-focus").blur();
                   
                },
                buttons: {









  2. /* CHECK TO SEE IF CONFIRM BOX AND DISPLAY CONFIRM BUTTON */

  3.                 if((confirmationBox) != undefined){
                 "Confirm" : function() {
                     window.location.href = targetUrl;
                 }

            "Close": function () {
                $(this).dialog("close");
            }
        }
    });