Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding custom HTML to jQuery dialog button pane

I want to add some custom HTML between the buttons on a jQuery dialog box (specifically a span that contains the word "or").

The Javascript I have is something like this:

$("#foo").dialog({
    autoOpen: false,
    width: 600,
    modal: true,
    resizable: false,
    buttons: {
        save: { text: 'Save', class: 'form-finish form-submit', click: function() {
                …
            }
        },
        cancel: { text: 'Cancel', class: 'form-cancel', click: function() {
            $( this ).dialog( "close" );
            }
        }
    }
});

The HTML it produces is this:

<button class="form-finish form-submit ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false"><span class="ui-button-text">Save</span></button>
<button class="close cancel ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false"><span class="ui-button-text">Cancel</span></button>

What I want is this:

<button class="form-finish form-submit ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false"><span class="ui-button-text">Save</span></button>
<span class="article">or</span>
<button class="close cancel ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false"><span class="ui-button-text">Cancel</span></button>

Is there any way to do this without hacking jQuery UI's core? Thanks!

like image 700
thebluelizard Avatar asked Oct 08 '22 20:10

thebluelizard


1 Answers

Do something like this after you create dialog?

  $(".form-finish").after("<span class='article'>or</span>");
like image 200
FiveTools Avatar answered Oct 13 '22 10:10

FiveTools