Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to change buttons on JQuery modal dialog box.

Posted on 2016-07-28
5
Medium Priority
?
88 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article discusses how to create an extensible mechanism for linked drop downs.
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…
Suggested Courses

927 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