The dialog widget does not provide this behavior out of the box. You can crack the behavior yourself, but it can break when upgrading to new releases of jquery-ui. Here's how I did it:
$('#my-dialog').dialog({
buttons: {
'hello world': function() { alert('hello world'); },
'good bye': function() { alert('goodbye'); }
},
open: function(event, ui) {
var dialog = $(this).closest('.ui-dialog');
var originalButtons = $('.ui-dialog-buttonpane', dialog)
var clonedButtons = originalButtons.clone().addClass('clone');
$('.ui-dialog-titlebar', dialog).after(clonedButtons);
$('button', clonedButtons).click(function() {
var button = $(this);
var buttonIndex = $('button', clonedButtons).index(button);
$('button:eq(' + buttonIndex + ')', originalButtons).click();
});
}
});
source
share