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 4613144
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:30:16+00:00 2026-05-22T01:30:16+00:00

I am trying to add a new button to a jquery UI Dialog box

  • 0

I am trying to add a new button to a jquery UI Dialog box based upon some input.

My code looks like this:

function editTour(ID, myDate) {
$.post("/Admin/EditTour", { TourID: ID },
        function (data) {
            $('#EditTour').html(data);
            $('#EditTour').dialog({
                modal: true,
                width: 400,
                resizable: false,
                title: formatDate(myDate),
                buttons: {
                    "Save": function () {
                      //some junk logic removed
                     },
                    "Cancel": function () {
                        $(this).dialog("close");
                    }
                }
            });

        });   //end post
}

What I want to do in this function is add a “Delete” button if the ID passed in is 0.

I know I can just create a cut and paste copy of the editTour function to manually add in the “Delete” button… but I was hoping for something cleaner.

  • 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-22T01:30:17+00:00Added an answer on May 22, 2026 at 1:30 am

    Try this, it may help you.

    function editTour(ID, myDate) {
        $.post("/Admin/EditTour", { TourID: ID },
            function (data) {
                $('#EditTour').html(data);
                $('#EditTour').dialog({
                    modal: true,
                    width: 400,
                    resizable: false,
                    title: formatDate(myDate)
                });
    
                var myButtons = {
                    "Save": function () {
                        //some junk logic removed
                    },
                    "Cancel": function () {
                        $(this).dialog("close");
                    }
                };
    
                if(ID == 0) {
                    myButtons["Delete"] = function() {
                        // Delete logic here.
                    }
                }
    
                $('#EditTour').dialog('option', 'buttons', myButtons);
            }
        );   //end post
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a new node to an jQuery SimpleTree , but all
I'm fairly new to JQuery and I'm trying to add multiple form fields for
I'm trying to set the HttpRequestHeader for a HttpWebRequest like so: new HttpWebRequest().Headers.Add(HttpRequestHeader.UserAgent, Mozilla/4.0);
New to javascript and jQuery, but I'm trying to dynamically add buttons and then
I am trying to add the remove buttons dynamically from a jQuery UI Dialog,
I am trying to add this HTML also when a input field is added:
I have a Node.js/Jade-based site and I'm trying to add some interactivity with some
I am trying to code ADD & DELETE button in HTML page to delete
I'm trying to add new output column using synchronous custom data flow component(below is
I am trying to add a new menu item to Eclipse's popupmenus. It really

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.