Upon opening a jQueryUI Dialog, I would like to perform a GET request, and based on the response, change the button text. After hours of struggling, I finally got the following working. Is this really the best/only? Thanks
$("#dialog").dialog({
open : function() {
var dialog=$(this);
$.get('ajax.php', function (data) {
var buttons=dialog.dialog( "option", "buttons" );
buttons[1].text=(data==1)?"CANCEL":"CLOSE";
var buttons=dialog.dialog( "option", "buttons" ,buttons);
});
},
buttons : [
{
text : 'SAVE',
click : function() {}
},
{
text : 'CANCEL',
click : function() {}
}
]
});