简体   繁体   中英

Multiple buttons in jquery ui dialog only one shows

Here is the fiddle. I have looked at the question ' How to add multiple buttons in Jquery UI dialog box? ', but the methods mentioned there did not work. The accepted one was:

$("#mydialog").dialog({
    buttons: {
        'Confirm': function() {
            //do something
            $(this).dialog('close');
        },
        'Cancel': function() {
            $(this).dialog('close');
        }
    }
});

feel free to revise my fiddle and notify me!

The method in the question you linked does work. Your fiddle is incorrect. It has

$('#dialog').dialog({
    modal: true,
    dialogClass: 'no-close',
    buttons: [{
        text:'OK',
        click: function () {
             $(this).dialog('close');
        },
        text:'Cancel',
        click: function () {
             location.reload();
        }
    }]
});

If you change this to the format shown in the question you linked

$('#dialog').dialog({
     modal: true,
     dialogClass: 'no-close',
     buttons: {
         'OK' : function () {
             $(this).dialog('close');
         },
         'Cancel' : function () {
             location.reload();
         }
     }
 });

you get two buttons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM