When using jQuery UI the buttons for a modal can be set-up after init like so:
$( ".selector" ).dialog( "option", "buttons", { "Ok": function() { $(this).dialog("close"); } } );
However what I'd like to do is add multiple buttons, dependent on logic conditions:
if ( canClose ){
$( ".selector" ).dialog( "option", "buttons", { "Ok": function() { $(this).dialog("close"); } } );
}
if ( canAlert ){
$( ".selector" ).dialog( "option", "buttons", { "Ok": function() { alert('Hello'); } } );
}
However the above code won't work correctly, as it resets the buttons array each time.
How can I add X number of buttons using logic, without loosing any existing buttons?