Solved

How to change buttons on JQuery modal dialog box.

Posted on 2016-07-28
5
68 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

734 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