in Education by
Is there a way to control which buttons to display in a Jquery Dialog? Scenario: Perhaps there might be program logic whereby after saving the data, the dialog is then able to show a "Delete" button. (meaning after a form submit within the dialog, the entire dialog refreshes? >> this includes the buttons on the dialog being loaded?) Any advice? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You can do this using the getter and setter methods on the buttons options on the jQuery dialog. The following example is taken from the jQuery UI docs: //getter var buttons = $( ".selector" ).dialog( "option", "buttons" ); //setter $( ".selector" ).dialog( "option", "buttons", [ { text: "Ok", click: function() { $(this).dialog("close"); } } ] ); So in your example you could do: Adding // Get existing buttons var buttons = $( ".selector" ).dialog( "option", "buttons" ); // Add a delete button buttons.push({ text: "Delete", click: function () { // Do your deletion stuff } }); // Put the modified button Array back in $( ".selector" ).dialog( "option", "buttons", buttons ); Removing // Get existing buttons var buttons = $( "#testDialog" ).dialog( "option", "buttons" ); $.each(buttons, function (i) { if (this.text === "Delete") { // We've found the button we want to delete so remove it from Array buttons.splice(i, 1); // No point in continuing the loop as we've removed what // we want to remove. return; } }); // Put the modified button Array back in $( "#testDialog" ).dialog( "option", "buttons", buttons ); Here's a working example.

Related questions

0 votes
    Have jquery dialog as closeOnescape as false. want to trigger an event based on esc key press how do ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I used the example from here http://jqueryui.com/demos/dialog/#animated to create a dialog box. The ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I am trying to build a Rails 3.1 app in which users can preview individual pages of documents or ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I have an elasticsearch kafka-connect connector consuming some topics. With the following configuration: { connection ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I have an elasticsearch kafka-connect connector consuming some topics. With the following configuration: { connection ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I have to put an input on the site from Excel file which I have done successfully. The only thing i got stuck ... as per the Excel file Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have to put an input on the site from Excel file which I have done successfully. The only thing i got stuck ... as per the Excel file Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    4. Read the given conversation and select the infinitive : Dinesh : What is your aim in life? Anupama : I want ... pilot? Anupama : Yes Select the correct answer from above options...
asked Dec 20, 2021 in Education by JackTerrance
0 votes
    How is fly by wire system implemented in an aircraft? a) By using control rods and linkages connecting ... computers and actuators to control surfaces d) Artificial intelligence...
asked Dec 25, 2020 in Technology by JackTerrance
0 votes
    I made the following plot in my Rmarkdown file, and render it using Xaringan. --- title: "myTitle ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    Rendered font in IE7 width is bigger than in other borwsers ( Top image part is IE9, bottom part ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    Can anyone see my syntax error? The jsTree just wouldn't render. plus a strange error in jquery 1 ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    Can anyone see my syntax error? The jsTree just wouldn't render. plus a strange error in jquery 1 ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    Rendered font in IE7 width is bigger than in other borwsers ( Top image part is IE9, bottom part ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    Rendered font in IE7 width is bigger than in other borwsers ( Top image part is IE9, bottom part ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
...