I would like to have more than one button. I tried to copy code between brackets but doesnt work.Ideas?
buttons: {
"Close": function() {
$(this).dialog("close");
}
To add to this, the button array method is useful to know about as it exposes more functionality per button, such as adding icons and other per-button properties. The points to note being the added square brackets around the set of buttons turning it into an array of buttons, and the extra curly braces around each button object.
$("#mydialog").dialog({
buttons: [{
text: 'Confirm',
icons: {
primary: "ui-icon-check"
},
click: function() {
//do something
$(this).dialog('close');
}},{
text: 'Cancel',
icons: {
primary: "ui-icon-cancel"
},
click: function() {
$(this).dialog('close');
}
}]
});
Create them using this format, 'button text': function() { }
with a comma inbetween, like this:
$("#mydialog").dialog({
buttons: {
'Confirm': function() {
//do something
$(this).dialog('close');
},
'Cancel': function() {
$(this).dialog('close');
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With