Solved

How to change buttons on JQuery modal dialog box.

Posted on 2016-07-28
5
51 Views
Last Modified: 2016-07-29
This is the exact code I am using to display a JQuery dialog box. It works great, however it displays two buttons. One labeled "Yes" and another labeled "No". I only need one button on
the Dialog box, and I need it to be labeled as "Ok". Is there any way to only have one button, and to have the text read as "Ok". How can I do that?

function displayDialogBox() {
 $('<div></div>').appendTo('body')
  .html('<div><h6>Alert </h6>
   .dialog({
                      modal:true, title: 'Did not perform process', zIndex:10000, autoOpen: true,
                      width: '600', resizable: false,
                      buttons: {
                                        Yes: function() {
                                         $(this).dialog("close");
                                          Reset();
                                       },
                                       No: function() {
                                         $(this).dialog("close");
                                                       Reset();
                                       }
                                   });

function Reset()
{
   // Code not shown
}
0
Comment
Question by:brgdotnet
  • 3
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
Branislav Borojevic earned 500 total points
ID: 41733979
From what I can see in the code, all you need to do is remove the
,
                                       No: function() {
                                         $(this).dialog("close");
                                                       Reset();
                                       }

Open in new window

from your code.

Try replacing the code with this:

function displayDialogBox() {
 $('<div></div>').appendTo('body')
  .html('<div><h6>Alert </h6>
   .dialog({
                      modal:true, title: 'Did not perform process', zIndex:10000, autoOpen: true,
                      width: '600', resizable: false,
                      buttons: {
                                      OK: function() {
                                         $(this).dialog("close");
                                          Reset();
                                       }
                                   });

function Reset()
{
   // Code not shown
}

Open in new window

0
 
LVL 2

Author Comment

by:brgdotnet
ID: 41734116
Hello Sir, I tried that earlier today, and it did not work. Possibly someone else has a recommendation.
0
 
LVL 4

Expert Comment

by:Branislav Borojevic
ID: 41734140
Can you reveal more of the code?

What is the alert for?

Maybe I can suggest a different solution to get the same result.

SIncerely,

Branislav
0
 
LVL 2

Author Comment

by:brgdotnet
ID: 41734657
Thank you Sir. I will try some things and get back with you.
0
 
LVL 2

Author Closing Comment

by:brgdotnet
ID: 41735423
Thank you. I think the Capitalization of the OK, (Instead of Ok) did the trick. Not sure. It works now though. I will dig into the guts of the code on Monday. Thank you.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Full Screen problem when auto scale IFRAME 2 82
Form with Modals 16 57
jQuery delay animation 3 31
PHP Form Calculate Total Price 10 44
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question