Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace dialog header in jQuery UI?

I want to remove dialog header in jQuery UI and add my close button. Close button is image, when user click image, dialog'll be closed. This my snippet:

$("#dialog-model").dialog({
    create: function (event, ui) {
        jQuery(".ui-dialog-titlebar").hide();
        $("#dialog-model").css({ 'font-family': 'Helvetica', 'padding': '0', 'font-size': '12px' });
    },
    height: 500,
    width: 900,
    modal: true,

});

I try to add image in scipt but it doesn't work

like image 892
Nathan Nguyễn Avatar asked Dec 22 '25 02:12

Nathan Nguyễn


1 Answers

UPDATE ANSWER

Try this one? DEMO http://jsfiddle.net/yeyene/GnpQ8/2/

Create a custom close button.

$(document).ready(function(){
    $("#dialog-model").dialog({
        create: function (event, ui) {
            $('.ui-dialog-titlebar').css({'background':'none','border':'none'});
            $(".ui-dialog-titlebar").html('<a href="#" role="button"><span class="myCloseIcon">close</span></a>');
            $("#dialog-model").css({ 'font-family': 'Helvetica', 'padding': '0', 'font-size': '12px' });
        },
        width: 250,
        height: 150,       
        modal: true,
        resizable: false
    });
    
    $("span.myCloseIcon").click(function() {
        $( "#dialog-model" ).dialog( "close" );
    });
});    
like image 79
yeyene Avatar answered Dec 23 '25 18:12

yeyene



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!