Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery dialog replace close button icon

I want change the default close icon button in jquery Dialog.

I tried to add this css class in jquery-ui-1.8.23.custom.css:

.ui-icon-myCloseButton { background-image: url(/path/image.png); }

and in the Dialog Definitions:

$('#documentsDialog').dialog({
   create: function(event,ui) {
           var widget = $(this).dialog("widget");
           $(".ui-dialog-titlebar-close span",widget).removeClass("ui-icon-closethick").addClass(".ui-icon-myCloseButton");

});

but no luck, any idea?

like image 229
Bruno Mósca Avatar asked Oct 31 '12 16:10

Bruno Mósca


1 Answers

You were just missing a closing curly bracket:

$('#documentsDialog').dialog({
    create: function(event, ui) {
        var widget = $(this).dialog("widget");
        $(".ui-dialog-titlebar-close span", widget).removeClass("ui-icon-closethick").addClass("ui-icon-myCloseButton");
    }
});​

But, most important, your css class should be declared as:

.ui-icon.ui-icon-myCloseButton{
    background-image: url(https://www.goldbroker.com/pages/images/close.png);
}​

The thing is that the definition at .ui-icon was overriding your custom image. When you redefine using the css above, it fully works.

Here, have a fiddle: http://jsfiddle.net/adrianonantua/FuWsK/2/

like image 74
Adriano Carneiro Avatar answered Nov 01 '22 01:11

Adriano Carneiro