Been playing with the accordion function over @ http://fmarcia.info/jquery/accordion.html
 
Couldn't get it to work with the latest jQuery build until I noticed something weird:
 
The script worked when I change the running variable to "3":
 
running = 3;
 
Upon further investigation, it appears the the slideDown call is firing the callback twice. If you run the following code, you'll notice that the slideUp callback alerts once and the slideDown callback alerts twice. Is this a bug or am I misunderstanding something?
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title></title>  
  <script type="text/_javascript_" src=""></script>
  <script language="_javascript_" type="text/_javascript_">//<![CDATA[
    
   $.accordian = function(l, b, a) {
 
    var active = a,
     running = 0;
    $(b).not(active).hide();
    $(l).click(function(e){
      
      var p = $('div', this.parentNode);
      if (running || !p.is(":hidden")) return false;
      
      running = 2;
      $(active).slideUp('fast', function(){--running;alert('sliding Up ' + running);});
      active = '#' + p.slideDown('slow', function(){--running;alert('sliding Down ' + running);}).get(0).id;
      
      return false;
     })
   };
   
   $(document).ready(function(){
    $.accordian('#main/div/a','#main/div/div','#diva');
   });
  //]]></script>
 </head>
 <body>
  <div id="main">
    <div id="div1">
   <a href="">Title of First Level</a>
   <div id="diva">
     <div>
    consectetuer adipiscing elit<br/>
    Sed lorem leo<br/>
    lorem leo consectetuer adipiscing elit<br/>
    Phasellus sem leo
     </div>
   </div>
    </div>
    <div id="div2">
   <a href="">Title of Second Level</a>
   <div id="divb">
     <div>
    bibendum at, eros<br/>
    Cras at mi et tortor egestas vestibulum<br/>
    Phasellus sem leo
     </div>
   </div>
    </div>
    <div id="div3">
   <a href="">Title of Third Level</a>
   <div id="divc">
     <div>
    Morbi eros massa<br/>
    interdum et, vestibulum id, rutrum nec<br/>
    bibendum at, eros<br/>
    Cras at mi et tortor egestas vestibulum<br/>
    Phasellus sem leo
     </div>
   </div>
    </div>
  </div>
 </body>
</html>
 
 
Thanks for any help!

Neil
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to