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
Solved

jquery dialog fadeIn issue

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

809 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