Customizing jQuery UI Dialog: hiding close button and changing opacity

Sometimes when you are programming small things are the hard things, little details becomes difficult to solve and you need to spend lot of time to solve them. This is logically :) because you spent the major part of your time thinking and designing the big or complex things, leaving in a second plane the small things and because this they became the new “big” things. Ok, stop talking with buggy sentences and talk about this post. Recently I was working in a web page using jQuery UI dialogs that have a couple of special requirements that takes me some time and because this I want to share here with you:

  • Some dialogs must not have a close button. There are dialogs that must be always visible floating at some part with some controls.
  • Some dialogs must have a degree of opacity allowing view the underlaying content and becomes more opaque when the cursor enters in the dialog.

Next are samples about how customize minimally the dialog to achieve the previous requirements. You can see them in action in the next sample page.

Creating a default dialog

Create a default jQuery UI dialog is easy, given a ‘div‘ element identified by d1:

Creating a dialog without close button

To creating a dialog without a close button, the key is the ‘open‘ method. We need to reference the ‘.ui-dialog-titlebar-close’ element and hide it:

Creating a dialog that changes opacity

Finally to create a fashion dialog that changes its opacity with the mouse hover event:

Do yo know how to create more stunning dialogs?
Comments are welcome.

Related Posts:

4 Responses

  1. TeMc September 3, 2011 / 19:23

    The code to hide the close button is relying on something that one should never ever rely on. The structure of the dialog could change at any time.

    Please make use of context:

    closeOnEscape: false,
    open: function(event, ui) {
    // Hide close button

  2. Robert December 22, 2011 / 22:37

    TeMc: Thanks for this topic, this is what I was looking for (hiding the close button). Your code is working fine.

    asantiago: I understand your concern and I stick to it. However I can’t have your code running, just replacing :




    Any ideas?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">