Solved

jquery dialog fadeIn issue

Posted on 2012-04-03
4
770 Views
Last Modified: 2012-04-04
fiddle : http://jsfiddle.net/loren_hibbard/ChXbr/

I'm trying to use the jquery dialogue box, but cannot figure out how to make it fadeIn when it appears and fadeOut when it is closed. if I do something like

// Dialog           
$('#dialog').dialog({
   autoOpen: false,
   modal: false,
   width: 600,
   modal: true,
   show: 'fadeIn(300)'
});

Open in new window

the modal sort of slides in with that weird jquery effect where all the text inside is constantly having its justification and formatting adjusted. I'd like just a normal fade in where the content sort of smoothly materializes ( http://www.bennadel.com/resources/presentations/jquery/demo5/index.htm ). Also, is there anyway to make the modal overlay a bit darker. And how come when I delete the paragraph of seemingly unrelated text, the modal stops working!

Thanks so much for taking a look at these random questions.
0
Comment
Question by:hibbsusan
4 Comments
 
LVL 5

Expert Comment

by:Robin Hall
ID: 37803147
Hi,

I was able to get it to Fade-In somewhat by adding an onclick event to the a tag like so:

<p><a href="#" id="dialog_link" onclick="$('#dialog').fadeIn(1000)"  class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-newwin"></span>Open Dialog</a></p>

This causes it to fade in.  To Fade-Out, I added an option to the dialog piece:

 // Dialog            
                $('#dialog').dialog({
                    autoOpen: false,
                    modal: false,
                    width: 600,
                    modal: true,
                    hide: 'fadeout',                                    
                });

Here it is on fiddle as well (hopefully...haven't used it before) Fiddle

As to the overlay colors, you would need to overwrite the css for those tags.  The one I tried was .ui-widget-overlay {background-color: black}.  You can see it changes things if you add it in but there are other tags as well you would probably need to change.  Firebug or IE Developer Tools can help you with that.

As to the last point about the paragraph.  I'm not sure.  I would double check to make sure that you aren't accidentally deleting a coding tag or something like that.  I tried deleting things on fidler and didn't have any issue so I couldn't replicate it on my end.

Hope that helps some.
0
 
LVL 6

Accepted Solution

by:
uzzidesign earned 500 total points
ID: 37803388
I took the same approach, added the fade to your click callback. (Also, wasn't sure if you wanted it on the whole popup, or on just the paragraph, I took the liberty of fading the whole thing).

http://jsfiddle.net/ChXbr/5/
// Dialog Link
$('#dialog_link').click(function(){
    $('.ui-dialog, .ui-widget-overlay').fadeIn(1000);                        
    $('#dialog').dialog('open');
    return false;
});

Open in new window

I also added some CSS to make the opacity of the modal overlay darker.
.ui-widget-overlay {
    opacity: 0.8;
}

Open in new window

0
 
LVL 7

Expert Comment

by:designatedinitializer
ID: 37804441
here's your solution:
                $('#dialog').dialog({
                    autoOpen: false,
                    width: 600,
                    modal: true,
                    show: 'fade',
                    hide: 'fade'
                });

Open in new window

0
 

Author Closing Comment

by:hibbsusan
ID: 37806433
Thanks for your help. looks nice! Just for the archive, this solution seems to work as well

$("#dialog").dialog({
    autoOpen: false,
    show: {
        effect: 'fade',
        duration: 2000
    },
    hide: {
        effect: 'fade',
        duration: 1000
    }
});

Open in new window


Also, thanks for helping me with the opacity of the background. Works like a charm.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question