Solved

jquery dialog fadeIn issue

Posted on 2012-04-03
4
767 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
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 to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now