1

I want to call the default action of dialogue box button, so please tell me how to pass the variable in side the dialogue box initialization. Here is my try for that :

Calling the dialogue box with default function of 'Yes' button

$( "#confirmComplete" ).dialog( "option", "buttons:Yes");

$( "#confirmComplete" ).dialog({
     autoOpen: false,
     resizable: false,
     modal: true,
     async:false,
     position: 'top',
     buttons: {
         "Yes": function() {
                //SOME FUNCTIOANLITY
         }
     }
 })
1

2 Answers 2

2

Put the code in a named function, call the function:

function doYes() {
    // some functionality
}

$("#confirmComplete").dialog({
    autoOpen: false,
    resizable: false,
    modal: true,
    async: false,
    position: "top",
    buttons: {
        "Yes": doYes
    },
});

doYes(); // Call the default button action
Sign up to request clarification or add additional context in comments.

Comments

0

You could do:

buttons: {
  "Yes": function() {
    $(this).dialog("close");
    return true;
  }
}

You could also have a No button that closes dialog and return false;

Based on the true/false returned, you can take further actions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.