Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6747779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:29:05+00:00 2026-05-26T12:29:05+00:00

I know the correct way to manage JQuery.dialog is to initialize with: $(#dialog).dialog({ autoOpen:

  • 0

I know the correct way to manage JQuery.dialog is to initialize with:

$("#dialog").dialog({ autoOpen: false });

Then use the following to open and close it:

$("#dialog").dialog("open");
$("#dialog").dialog("close");

But there are some cases when this model is not fully applicable.

For instance, I use a dialog to create new data and to edit existing data. In the first case I have a cancel and a create button, but in the second case I have also a delete button.

I’ve seen that there is a destroy function in jquery.dialog. The question is: in these cases, should I destroy the dialog instead of close it and create a new one? There is any better option?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:29:06+00:00Added an answer on May 26, 2026 at 12:29 pm

    jQuery UI dialog allows you to manipulate most properties after initialization. You can change the buttons some time after the dialog is initialized; e.g. when the insert or update button is clicked.

    // imported from http://jsfiddle.net/salman/VYAJw/9/
    
    $(function() {
      $("#dialog1").dialog({
        autoOpen: false,
        modal: true
      });
      $("#button-insert").click(function() {
        $("#dialog1").dialog("option", "title", 'Insert Record');
        $("#dialog1").dialog("option", "buttons", [{
          text: "Insert",
          click: function() {
            alert("Record inserted");
            $(this).dialog("close");
          }
        }, {
          text: "Cancel",
          click: function() {
            $(this).dialog("close");
          }
        }]);
        $("#dialog1").dialog("open");
      });
      $("#button-update").click(function() {
        $("#dialog1").dialog("option", "title", 'Update Record');
        $("#dialog1").dialog("option", "buttons", [{
          text: "Update",
          click: function() {
            alert("Record updated");
            $(this).dialog("close");
          }
        }, {
          text: "Delete",
          click: function() {
            alert("Record deleted");
            $(this).dialog("close");
          }
        }, {
          text: "Cancel",
          click: function() {
            $(this).dialog("close");
          }
        }]);
        $("#dialog1").dialog("open");
      });
    });
    @import url("https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/blitzer/jquery-ui.min.css");
    body {
      font: medium sans-serif;
    }
    
    #dialog1 label,
    #dialog1 input {
      display: block;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
    
    <div id="dialog1">
      <p>Fill out this form.</p>
      <form>
        <fieldset>
          <label for="name">Name</label>
          <input type="text" name="name" id="name" />
          <label for="email">Email</label>
          <input type="text" name="email" id="email" />
          <label for="password">Password</label>
          <input type="password" name="password" id="password" />
        </fieldset>
      </form>
    </div>
    <input type="button" id="button-insert" value="Insert" />
    <input type="button" id="button-update" value="Update" />

    An alternate method would be to add the buttons directly inside the form and .hide() them depending on whether you’re showing insert or update dialog.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know the correct way to explicitly specify which rules Gendarme will use?
Hey all, title may be abit misleading but i didnt know the correct way
I want to know is below code correct ? I have following code which
I know this is probably possible using Streams, but I wasn't sure the correct
I'm new to rails and don't even know if this is the correct way
Does anyone know the correct definition for a sliding window in WPF? What I
Please let me know whether its correct or not? I am mapping the whole
I read the MSDN documentation and examples here and I know that the correct
Does anyone know how to get the correct mouse position during a drag-and-drop operation
Firstly I know that there are many question and solutions to correct thread marshalling

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.