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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:39:09+00:00 2026-05-30T06:39:09+00:00

For learning jQuery UI dialog, I have the code defined below. I need to

  • 0

For learning jQuery UI dialog, I have the code defined below.

I need to do following three tasks

1) Use my image as “OK” button and “Cancel” button

2) Use my custom image as the close button on right top end of dialog

3) Background of the whole dialog should be “gray” (including title, and place for OK button.)

The important point is the style should be applied only to my dialog. All other widgets should have default behavior. For content area, I could achieve it using #myDiv.ui-widget-content.

Can you please suggest code for this?

Note: Please use the best practices, if possible. (E.g. 1. use a variable $myDialog 2. use autoOpen: false)

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">
    <title> </title>

    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.js"></script>

    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.6/jquery-ui.js"></script>


 <link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.13/themes/redmond/jquery-ui.css" rel="stylesheet" 
        type="text/css" />


     <link href="Styles/OverrideMyDialog.css" rel="stylesheet" 
        type="text/css" />-



<script type="text/javascript">

    $(document).ready(function () {
        var $myDialog = $(".addNewDiv").dialog(
                                    {
                                        autoOpen: false,
                                        title: 'My Title',
                                        buttons: { "OK": function () {
                                            $(this).dialog("close");
                                            ShowAlert();
                                            return true;
                                        },
                                            "Cancel": function () {
                                                $(this).dialog("close");
                                                return false;
                                            }
                                        }

                                    }
                                           );





        $('#myOpener').click(function () {
            return $myDialog.dialog('open');


        });
    });

    function ShowAlert() {
        alert('OK Pressed');
    }

</script>

<body>
    <div>
    <input id="myOpener" type="button" value="button" />
</div>
<div class="addNewDiv"  id="myDiv" title="Add new Person" >
    <table>
        <tr>
            <td>
                Name
            </td>

        </tr>
        <tr>
            <td>
                Age
            </td>

        </tr>
    </table>
</div>
</body>
</html>

Also, I made a css class to override the widget functionality only for my dialog

    /*
   *File Name: OverrideMyDialog.css
   * jQuery UI CSS is overriden here for one div
  */


/* Component containers
----------------------------------*/

#myDiv.ui-widget-content 
{ 
border: 5px solid Red;
background: Gray url(images/ui-bg_inset-hard_100_fcfdfd_1x100.png) 50% bottom repeat-x;
color: Green; 
} 
  • 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-30T06:39:10+00:00Added an answer on May 30, 2026 at 6:39 am

    I have upvoted the above answer. Still dialogClass: ‘myDialogCSS’ was the key I was looking for.

    HTML and jQuery

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-
        1.4.4.js"></script>
        <script type="text/javascript"
            src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.6/jquery-ui.js"></script>
        <link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.13/themes/Sunny/jqueryui.
        css"
            rel="stylesheet" type="text/css" />
        <link href="Styles/MyStyleSheet.css"
            rel="stylesheet" type="text/css" />
    
        <script type="text/javascript">
            $(document).ready(function () {
                var $myDialog = $(".addNewDiv").dialog(
                {
                    modal: true,
                    autoOpen: false,
                    dialogClass: 'myDialogCSS',
                    title: 'My Title',
                    closeOnEscape: false,
                    open: function(event, ui)
                    {
                        //Disable OK Button
                        $(".ui-dialog-buttonpane
                            button:contains('OK')").attr("disabled", true).addClass("ui-state-disabled");
                    },
                    buttons: { "OK": function ()
                    {
                        $(this).dialog("close");
                        ShowAlert();
                        return true;
                    },
                        "Cancel": function ()
                        {
                            $(this).dialog("close");
                            return false;
                        }
                    }
                }
                );
                $('#myOpener').click(function ()
                {
                    return $myDialog.dialog('open');
                });
            });
            function ShowAlert() {
                alert('OK Pressed');
            }
        </script>
    </head>
    
    <body>
        <div>
            <input id="myOpener" type="button" value="button" />
        </div>
        <div class="addNewDiv" id="myDiv" title="Add new Person">
            <table>
                <tr>
                    <td>Name
    
                    </td>
                </tr>
                <tr>
                    <td>Age
                    </td>
                </tr>
            </table>
        </div>
    </body>
    </html>
    

    MyStyleSheet.css

       /*Title Bar*/
       .myDialogCSS .ui-dialog-titlebar
         {
           /*Hide Title Bar*/
           /*display:none; */
         }
    
       /*Content*/
       .myDialogCSS .ui-dialog-content
         {
           font-size:30px;
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning jQuery. I have the following chunk of code in an HTML
So I'm learning jQuery Mobile and I'm trying to run the following code below
I am learning JQuery. I have a need to create a custom control. This
I am learning jQuery and as part of that i tried following code.. It
I'm learning JQuery and have found the factory function $() with its selectors quite
I am learning JQuery, and I have ran into an odd issue. I made
I have just started learning Jquery and am new to writing javascript (I am
Learning jquery, so please be kind :) Using PHP, I have a table with
I'm learning jQuery/javascript and have a rather basic question. Why doesn't this work? Thanks
I am a novice learning jQuery and I have a scenario; I have 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.