Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

jquery dialog fadeIn issue

Posted on 2012-04-03
4
Medium Priority
?
780 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

636 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