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

  • Home
  • SEARCH
  • 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 997703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:04:36+00:00 2026-05-16T07:04:36+00:00

I have an issue where I’m reusing the dialog so I wouldnt have to

  • 0

I have an issue where I’m reusing the dialog so I wouldnt have to duplicate the code. The issue I’m having is when I click an “Add New” button, I have as button “save” and “cancel”. The save button in the dialog handles saving the information. If I click the “Edit Existing” button to edit my information, I would like the “save” button to change to an “edit” button. Is this possible?

  • 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-16T07:04:37+00:00Added an answer on May 16, 2026 at 7:04 am

    I think what you’re trying to do is, at runtime, change the text of the buttons depending on the user action. This discussion involving Richard Worth may help, and it’s what I’ve had to use in order to accomplish what you’re trying to do.

    Basically, what you are trying to do isn’t possible by defining the buttons array as an object literal (inline in the dialog definition). What you should do is define your buttons array outside the dialog initialization; your array indexes can be your label text (as you’ll see in the message discussion example). Then, when you initialize the array, you just assign the buttons property to your buttons array.

    In pseudo-code, you’ll do this:

    function createDialog(mode) {  //mode=new for dayClick; edit for eventClick
      var myButtons = {};  //initialize the object to hold my buttons
      if (mode === "new") {
        myButtons["Save"] = function() {...}  //the function that does the save
      } else {
        myButtons["Edit"] = function() {...}  //the function that edits
      }
      myButtons["Cancel"] = function() {...} //common cancel function for either new or edit mode
    
      //other logic
    
      $("#dialogAddEdit").dialog({
        ...
        buttons: myButtons,  //assign the buttons property to your myButtons array object
        ...
      });
    }
    

    Hope this helps!!

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

Sidebar

Related Questions

We have an issue on our page whereby the first time a button posts
Much of my sql code is generated (from POD). Now i have issue where
i have issue regarding Paging using filterexpression. here's the piece of code for filtering
Below is the code fragment I have issue with socket programing. Here after select
I have an issue where when a button is clicked and the process takes
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I have an issue that is driving me a bit nuts: Using a UserProfileManager
We have an issue using the PEAR libraries on Windows from PHP . Pear
We have an issue related to a Java application running under a (rather old)
I have some issue with a Perl script. It modifies the content of a

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.