Solved

jquery dialog fadeIn issue

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

762 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

23 Experts available now in Live!

Get 1:1 Help Now