2011-05-15 96 views
1

最近,我的朋友帮我修复了背景覆盖问题。我有一个问题,如果对话框的高度超出了原来的网站背景,它会在中间切掉叠加层。他的修复解决了它。jQuery UI对话框滚动条+覆盖设置不会卸载

但现在我有一个轻微但烦人的问题。每次我打开一个非常长的对话框,然后是一个较短的对话框,从更长的延伸的滚动条仍然存在。就像我之后打开短片一样,我可以像背景一样向后滚动,但我只能看到叠加层。我不认为一旦关闭对话框,设置就会正常卸载。

有没有办法解决这个问题?谢谢。

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/global.dwt" codeOutsideHTMLIsLocked="false" --> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<!-- InstanceBeginEditable name="Meta" --> 
<!-- InstanceEndEditable --> 
<!-- InstanceBeginEditable name="doctitle" --> 
<title>Ricky Tsang | Book | Bonus Features</title> 
<!-- InstanceEndEditable --> 
<link href="../../css/default.css" type="text/css" rel="stylesheet" /> 
<link href="../../css/plugins/jquery.jscrollpane.css" type="text/css" rel="stylesheet" /> 
<link href="../../css/plugins/custom-theme/jquery-ui-1.8.12.custom.css" type="text/css" rel="stylesheet" /> 
<link rel="shortcut icon" type="image/x-icon" href="http://www.dearricky.com/_rickytsang-ca/favicon.ico"> 
<!--[if IE 7]> 
<link href="../css/ie7.css" type="text/css" rel="stylesheet" /> 
<![endif]--> 
<!-- InstanceBeginEditable name="head" --> 
<!-- InstanceEndEditable --> 
<style> 
a img { 
    border:0 
} 
</style> 
<noscript> 
    <style> 
    #header #inner { width: 820px; } 
    #mainmenu { visibility: visible; } 
    </style> 
</noscript> 
</head> 

<body class="oneColElsCtrHdr"> 
<div id="header"> 
    <div id="top"> 
     <img src="../../images/logo.png" border="0" usemap="#Map" class="Logo" /> 
     <map name="Map" id="Map"> 
     <area shape="circle" coords="85,11,3" href="../../bird/" /> 
     </map> 
</div> 
    <div id="inner"> 
     <div id="mainmenu"> 
      <ul> 
       <li> 
        <a href="../../" class="first">HOME</a> 
       </li> 
       <li> 
        <a href="../../ricky/aboutricky/" class="first parent">RICKY</a> 
        <div class="sub"> 
         <ul> 
          <li><a href="../../ricky/aboutricky/" class="second">About Ricky</a></li> 
          <li><a href="../../ricky/disability/" class="second">Disability</a></li> 
          <li><a href="../../ricky/writing/" class="second">Writing</a></li> 
          <li><a href="../../ricky/questionsanswers/" class="second">Questions & Answers</a></li> 
         </ul> 
         <div class="clear"></div> 
        </div> 
       </li> 
       <li> 
        <a href="http://www.rickytsang.ca/blog/" class="first">JOURNAL</a> 
       </li> 
       <li> 
        <a href="../../advice/four/" class="first parent">ADVICE</a> 
        <div class="sub"> 
         <ul> 
          <li><a href="../../advice/four/" class="second">4 Steps To Mending A Broken Heart</a></li> 
         </ul> 
         <div class="clear"></div> 
        </div> 
       </li> 
       <li> 
        <a href="../ridiculous/" class="first parent">BOOK</a> 
        <div class="sub"> 
         <ul> 
          <li><a href="../ridiculous/" class="second">Ridiculous</a></li> 
          <li><a href="../excerpts/" class="second">Excerpts</a></li> 
          <li><a href="../bonusfeatures/" class="second">Bonus Features</a></li> 
          <li><a href="../wheretobuy/" class="second">Where To Buy</a></li> 
         </ul> 
         <div class="clear"></div> 
        </div> 
       </li> 
       <li> 
        <a href="../../music/" class="first">MUSIC</a> 
       </li> 
       <li> 
        <a href="http://www.rickytsang.ca/forum/" class="first">FORUM</a> 
       </li> 
       <li> 
        <a href="../../information/news" class="first parent">INFORMATION</a> 
        <div class="sub"> 
         <ul> 
          <li><a href="../../information/news/" class="second">News</a></li> 
          <li><a href="../../information/contact/" class="second">Contact</a></li> 
          <li><a href="../../information/links/" class="second">Links</a></li> 
          <li><a href="../../information/website/" class="second">Website</a></li> 
         </ul> 
         <div class="clear"></div> 
        </div> 
       </li> 
      </ul> 
     </div> 
     <div class="clear"></div> 
    </div> 
</div> 
<div id="container"> 
    <!-- InstanceBeginEditable name="AboveContainer" --> 

    <!-- InstanceEndEditable --> 
    <div id="topContent"></div> 
    <div id="mainContent"> 
     <!-- InstanceBeginEditable name="MainContent" --> 
     <div id="fixedHeightContent"> 
      <h1 align="justify">Bonus Features</h1> 
      <p><strong><em><a href="../ridiculous/">Ridiculous: The Mindful Nonsense of Ricky’s Brain</a></em> is jam-packed with hundreds of pages of writing, but there are always limitations when it comes to books.  Below are some extras that readers may find entertaining, kind of like a DVD!</strong></p> 
      <h2><strong><u>From The Book (with excerpts)</u></strong></h2> 
      <p><strong><a href="javascript:openDialog('../../pages/book/bonusfeatures/extras/2009-02-23-the-girl-who-saved-my-life.html');">The Girl Who Saved My Life</a></strong><br /> 
      A true story about an amazing girl who stole my heart.  Includes a photo and video of interesting items.</p> 
      <p><strong><a href="javascript:openDialog('../../pages/book/bonusfeatures/extras/2009-08-10-rickys-adventures-in-bikini-land.html');">Ricky’s Adventures In Bikini Land</a></strong><br /> 
      A satirical recount of my “adventures” in Niagara Falls.  Includes a window scene photo from the room where my family and I stayed.</p> 
      <p><strong><a href="javascript:openDialog('../../pages/book/bonusfeatures/extras/2009-08-25-the-brain-behind-his-words.html');">The Brain Behind His Words</a></strong><br /> 
      A brutally honest narrative of the things that go on inside my head.  Includes a full-size photo of myself that was an inspiration for the piece.</p> 
      <p><strong><a href="javascript:openDialog('../../pages/book/bonusfeatures/extras/2009-08-30-rickys-moments-of-wtf.html');">Ricky’s Moments Of WTF?!</a></strong><br /> 
      About the stranger happenings in the life of yours truly.  Includes a few photos of… embarrassing things.</p> 
      <p><strong><a href="javascript:openDialog('../../pages/book/bonusfeatures/extras/2010-05-09-appreciating-mothers-the-how-to-guide.html');">Appreciating Mothers: The How-To Guide</a></strong><br /> 
      A comical yet hopefully endearing guide on how to appreciate mothers.  Includes a poem I wrote about the uterus.</p> 
      <h2><strong><u>Pages That Didn’t Make It</u></strong> 
      </h2> 
      <p><strong><a href="javascript:openDialog('../../pages/book/bonusfeatures/deletedpages/2005-12-04-rickys-romantic-analogies.html');">Ricky’s Romantic Analogies</a></strong><br /> 
      No matter how much I edited this entry, it continued to remain… corny.  Though, it did become a pivotal part of the romantic ideas for my following writings.</p> 
      <p><strong><a href="javascript:openDialog('../../pages/book/bonusfeatures/deletedpages/2006-08-29-monkey-see-monkey-do.html');">Monkey See, Monkey Do</a></strong><br /> 
      This one seemed a little out of place for the book, despite the title.  It also had too many photos that only look good in colour.</p> 
     </div> 
     <!-- InstanceEndEditable --> 
    </div> 
    <div id="bottomContent"></div> 
</div> 

<div id="footer"> 
    <div class="social"> 
     <ul> 
      <li><a href="http://www.facebook.com/DearRicky/" target="_blank" title="Facebook"><img src="../../images/icons/facebook.png" /></a></li> 
      <li><a href="http://www.twitter.com/DearRicky/" target="_blank" title="Twitter"><img src="../../images/icons/twitter.png" /></a></li> 
     </ul> 
    </div> 
    <div class="copyright"> 
     Copyright &copy; 2011 Ricky Wai Kit Tsang. All rights reserved. 
    </div> 
</div> 

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script> 
<script type="text/javascript" src="../../scripts/global.js"></script> 
<script type="text/javascript" src="../../scripts/plugins/jquery-1.5.1.min.js"></script> 
<script type="text/javascript" src="../../scripts/plugins/jquery-ui-1.8.12.custom.min.js"></script> 
<script type="text/javascript" src="../../scripts/plugins/jquery.hoverIntent.js"></script> 
<script type="text/javascript" src="../../scripts/plugins/jquery.mousewheel.js"></script> 
<script type="text/javascript" src="../../scripts/plugins/jquery.jscrollpane.js"></script> 
<script type="text/javascript"> 
    $(function() { 
     $("#fixedHeightContent").jScrollPane({ 
      showArrows: true 
     }); 
    }); 
</script> 

<!-- InstanceBeginEditable name="Scripts" --> 
<!-- InstanceEndEditable --> 

</body> 
<!-- InstanceEnd --></html> 

CSS:

body { 
    background: url("../images/backgrounds/glowing-clouds.jpg") no-repeat scroll center 130px #000; 
    font-family: Arial, Verdana, Helvetica, sans-serif; 
    font-size: 12px; 
    margin: 0; 
    padding: 0; 
    text-align: center; 
    color: #000000; 
} 

a { 
    text-decoration: none; 
} 

a:hover { 
    text-decoration: underline; 
} 

h1 { 
    color: #000; 
    margin-bottom: 20px; 
    margin-top: 0px; 
} 

h2 { 
    color: #000; 
    font-size: 16px; 
} 

p { 
    font-size: 14px; 
    line-height: 18px; 
    margin-bottom: 10px; 
    margin-top: 0px; 
} 

.clear { 
    clear: both; 
} 

#container { 
    width: 880px; 
    margin: 20px auto 0px auto; 
    text-align: left; 
} 

#topContent { 
    background-image: url("../images/backgrounds/slider-top.png"); 
    background-repeat: no-repeat; 
    height: 15px; 
    margin-top: 40px; 
    width: 880px; 
} 

#mainContent { 
    background: transparent url("../images/backgrounds/slider-body.png") repeat-y scroll 0 0; 
    hasLayout: false; 
    padding: 1px 15px; 
    width: 850px; 
} 

#fixedHeightContent { 
    height: 440px; 
    outline: none; 
    overflow: auto; 
    padding: 20px; 
    width: 810px; 
} 

#bottomContent { 
    background-image: url("../images/backgrounds/slider-bottom.png"); 
    background-repeat: no-repeat; 
    height: 15px; 
    width: 880px; 
} 

#floatContent { 
    overflow: hidden} /**clears floats**/ 

.RightCaptions {/** container **/ 
    float: right; 
    width: auto; 
    height:auto; 
    border: thin silver solid; 
    margin: 0.5em; 
    padding: 0.5em; 
} 

.LeftCaptions {/** container **/ 
    float: left; 
    width: auto; 
    height:auto; 
    border: thin silver solid; 
    margin: 0.5em; 
    padding: 0.5em; 
} 

.RightCaptions p, .LeftCaptions p {/** text captions **/ 
    text-align: center; 
    font-style: italic; 
    font-size: small; 
    text-indent: 0; 
} 

#header { 
    margin: 0px 0px 10px; 
    position: relative; 
} 

#header #top { 
    background-color: #000; 
    margin: 0px auto; 
} 

#header #inner { 
    margin: 0px auto; 
    width: 820px; 
} 

#header img.Logo { 
    padding: 25px 0px 20px 0px; 
    position: relative; 
} 

#mainmenu { 
    float: right; 
} 

#mainmenu ul { 
    list-style: none; 
    margin: 0px; 
    padding: 0px; 
} 

#mainmenu ul li { 
    display: block; 
    float: left; 
} 

#mainmenu ul li a { 
    color: #fff; 
    display: block; 
    font-size: 14px; 
    font-weight: bold; 
    height: 35px; 
    line-height: 35px; 
    padding: 0px 15px; 
} 

#mainmenu ul li a:hover { 
    color: #999; 
    text-decoration: none; 
} 

#mainmenu ul li a.parent { 
    background: transparent url("../images/menu/menu-down.png") no-repeat center right; 
    margin-right: 15px; 
} 

#mainmenu .sub { 
    border: solid 1px #fff; 
    display: none; 
    position: absolute; 
    z-index: 1000; 
} 

#mainmenu .sub ul { 
    margin: 0px; 
} 

#mainmenu .sub li { 
    border: none; 
    display: block; 
    float: left; 
    height: auto; 
    padding: 0px; 
    width: auto; 
} 

#mainmenu .sub a { 
    color: #fff; 
    display: block; 
    font-size: 12px; 
    height: auto; 
    line-height: 16px; 
    padding: 5px 8px 7px; 
    text-align: left; 
} 

#mainmenu .sub a:hover { 
    background-image: none; 
} 

#footer { 
    margin: 0px auto; 
    padding-bottom: 60px; 
    width: 850px; 
    position: relative; 
    text-align: center; 
} 

#footer .social { 
    position: absolute; 
    top: 0; 
    left: 10px; 
} 

#footer .social ul { 
    list-style: none; 
    margin: 10px 0px 0px; 
    padding: 0px; 
} 

#footer .social li { 
    float: left; 
    margin-right: 5px; 
} 

#footer .social img { 
    border: 0px; 
} 

#footer .copyright { 
    color: #fff; 
    line-height: 32px; 
    margin-top: 10px; 
} 

/******************************* 
* Controls 
******************************/ 

.ImageRotator { 
    overflow: hidden; 
    position: relative; 
    width: 850px; 
} 

.ImageRotator ul { 
    list-style-type: none; 
    margin: 0px; 
    padding: 0px; 
    width: 9999px; 
} 

.ImageRotator ul li { 
    display: block; 
    float: left; 
    height: 440px; 
    width: 850px; 
    overflow: hidden; 
} 

.ImageRotator ul li img.gallery { 
    border: 0px; 
    height: 630px; 
    width: 850px; 
} 

.ImageRotator .toolbar { 
    background: url("../images/backgrounds/slider-toolbar.png") repeat scroll 0 0 transparent; 
    bottom: 0px; 
    color: #fff; 
    height: 36px; 
    left: 0px; 
    position: absolute; 
    width: 850px; 
    z-index: 100; 
} 

.ImageRotator .toolbar .desc { 
    font-weight: bold; 
    margin: 10px; 
    text-align: center; 
} 

.ImageRotator .toolbar .pages { 
    margin: 5px; 
    position: absolute; 
    right: 0px; 
} 

.ImageRotator .toolbar .pages div { 
    background: url("../images/backgrounds/page.png") repeat scroll 0 0 transparent; 
    color: #999; 
    cursor: pointer; 
    float: left; 
    font-weight: bold; 
    height: 22px; 
    padding-top: 6px; 
    text-align: center; 
    width: 28px; 
} 

.ImageRotator .toolbar .pages div.Active { 
    color: #0f75a7; 
} 

/******************************* 
* Pages 
******************************/ 

.popupDialog { 
    font-family: Arial, Verdana, Helvetica, sans-serif; 
    font-size: 12px; 
} 

脚本:

<script type="text/javascript"> 
function openDialog(url) { 
    $("<div class='popupDialog'>Loading...</div>") 
     .dialog({ 
      autoOpen: false, 
      closeOnEscape: true, 
      width: '900', 
      height: 'auto', 
      modal: true, 
      title: 'Bonus Features', 
      autoResize: true, 
      beforeClose: function(){ $(this).remove(); } 
     }).bind('dialogclose', function() { 
      jdialog.dialog('destroy'); 
     }).load(url, function() { 
      $(this).dialog("option", "position", ['center', 'center']).bind('dialogopen', function() { 
        adjustJQueryDialogOverlay(); 
       }); 
       $(this).dialog("open"); 
     }); 
} 

$(window).resize(function() { 
    $(".ui-dialog-content").dialog("option", "position", ['center', 'center']); 
}); 
</script> 
+0

您能通过[jsFiddle](http://jsFiddle.net)为我们重现此功能吗? – 2011-05-16 19:45:40

+0

不幸的是,我真的不知道如何。我可以在这里复制并粘贴所有必要的代码吗? – DearRicky 2011-05-16 20:02:34

+0

当然,如果你给我你正在使用的html/css/js,我可以尝试创建一个jsFiddle。 – 2011-05-16 20:19:47

回答

0

所以这里是我的朋友的答案。

基本上,覆盖是一个jQuery的bug,我必须搜索周围的解决方法,因为我发现你的resize方法有一点缺陷:P所以你可以做的是改变openDialog方法行(我们赢了'牛逼的呼叫adjustJQueryDialogOverlay法):

$(this).dialog("option", "position", ['center', 'center']); 

$(this).dialog("open"); 

而且你还需要从绝对更新了jQuery-UI-1.8.11.custom.css线41改变位置固定,并希望这将解决这个问题的背景!

function openDialog(url) { 
    $("<div class='popupDialog'>Loading...</div>") 
     .dialog({ 
      autoOpen: false, 
      closeOnEscape: true, 
      width: '900', 
      height: 'auto', 
      modal: true, 
      title: 'Bonus Features', 
      beforeClose: function(){ $(this).remove(); } 
     }).bind('dialogclose', function() { 
      jdialog.dialog('destroy'); 
     }).load(url, function() { 
      $(this).dialog("option", "position", ['center', 'center']); 
       $(this).dialog("open"); 
     }); 
} 

$(window).resize(function() { 
    $(".ui-dialog-content").dialog("option", "position", ['center', 'center']); 
}); 
0

嘛,你不应该被要求这样做,但是当我跑进同样的问题,我发现的最简单/最快的修复方法是在创建新的方法之前调用对话框的destroy方法之一。所以,你想尝试这样的事:

$(".ui-dialog-content").dialog("destroy"); 

这会立即转到你的脚本,在其中设置了新的对话框中前区。

HTH。

编辑:根据要求:

<script> 
function openDialog(url) { 
    $("<div class='popupDialog'>Loading...</div>").dialog("destroy"); 

    $("<div class='popupDialog'>Loading...</div>") 
     .dialog({ 
      autoOpen: false, 
      closeOnEscape: true, 
      width: '900', 
      height: 'auto', 
      modal: true, 
      title: 'Bonus Features', 
      autoResize: true, 
      beforeClose: function(){ $(this).remove(); } 
     }).bind('dialogclose', function() { 
      jdialog.dialog('destroy'); 
     }).load(url, function() { 
      $(this).dialog("option", "position", ['center', 'center']).bind('dialogopen', function() { 
        adjustJQueryDialogOverlay(); 
       }); 
       $(this).dialog("open"); 
     }); 
} 

$(window).resize(function() { 
    $(".ui-dialog-content").dialog("destroy"); 

    $(".ui-dialog-content").dialog("option", "position", ['center', 'center']); 
}); 
</script> 

应该只需要更新脚本的一部分。

+0

请参阅上文。我还建议花时间阅读/浏览至少一次jQuery UI API端到端 – 2011-05-17 07:02:26

+0

感谢你的帮助。非常感谢。不幸的是,它不起作用,但我的朋友回来了答案。我会尽快发布。 – DearRicky 2011-05-17 18:34:21