www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 11-22-2009, 05:53 PM
    metropolitica metropolitica is offline
    Registered User
     
    Join Date: Nov 2009
    Location: Toronto, Ontario, Canada
    Posts: 4
    resolved [RESOLVED] Accordion item will not reopen after closing

    As stated in the thread title, my JS accordion items will not re-open after closing.

    You can view it here.

    XHTML item sample:

    HTML Code:
    <div id="accordion">
       <dl class="accordion" id="slider">
          <dt>Item Heading</dt>
             <dd>                    
                <span>Sample accordion content.</span>
             </dd>
          </dt>
       </dl>
    </div>
    CSS:

    Code:
    #accordion {
    	width: 100%;
    	margin: 50px auto;
    	border: none;
    }
    .accordion {
    	width: 100%;
    	font: 12px Verdana,Arial;
    	color: #333;
    }
    .accordion dt {
    	padding: 3px 1px;
    	cursor: pointer;
    	background-color: #fff;
    	background-image: url('../images/arrow_down.gif');
    	background-position: right center;
    	background-repeat: no-repeat;
    	color: #666;
    }
    .accordion dt:hover {
    	background-color: #1883f1;
    	color: #fff;
    }
    .accordion .open {
    	background-color: #ddd;
    	background-image: url('../images/arrow_up.gif');
    	padding: 3px 10px;
    }
    .accordion dd {
    	overflow: hidden;
    	background-color: #f3f7fa;
    	margin: 0;
    	padding-left: 50px; 
    	border-bottom: 1px solid #ddd;
    }
    .accordion span {
    	display: block;
    	border-top: none;
    	padding: 15px;
    }
    Internal Javascript (before body tag)

    Code:
    <script type="text/javascript">
    	var slider=new accordion.slider("slider");
    	slider.init("slider",0,"open");
    </script>
    External Javascript

    Code:
    var accordion=function(){
    	var tm=sp=10;
    	function slider(n){this.nm=n; this.arr=[]}
    	slider.prototype.init=function(t,c,k){
    		var a,h,s,l,i; a=document.getElementById(t); this.sl=k?k:'';
    		h=a.getElementsByTagName('dt'); s=a.getElementsByTagName('dd'); this.l=h.length;
    		for(i=0;i<this.l;i++){var d=h[i]; this.arr[i]=d; d.onclick=new Function(this.nm+'.pro(this)'); if(c==i){d.className=this.sl}}
    		l=s.length;
    		for(i=0;i<l;i++){var d=s[i]; d.mh=d.offsetHeight; if(c!=i){d.style.height=0; d.style.display='none'}}
    	}
    	slider.prototype.pro=function(d){
    		for(var i=0;i<this.l;i++){
    			var h=this.arr[i], s=h.nextSibling; s=s.nodeType!=1?s.nextSibling:s; clearInterval(s.tm);
    			if(h==d&&s.style.display=='none'){s.style.display=''; su(s,1); h.className=this.sl}
    			else if(s.style.display==''){su(s,-1); h.className=''}
    		}
    	}
    	function su(c,f){c.tm=setInterval(function(){sl(c,f)},tm)}
    	function sl(c,f){
    		var h=c.offsetHeight, m=c.mh, d=f==1?m-h:h; c.style.height=h+(Math.ceil(d/sp)*f)+'px';
    		c.style.opacity=h/m; c.style.filter='alpha(opacity='+h*100/m+')';
    		if(f==1&&h>=m){clearInterval(c.tm)}else if(f!=1&&h==1){c.style.display='none'; clearInterval(c.tm)}
    	}
    	return{slider:slider}
    }();
    Anyone that can help, it would be greatly appreciated.
    Reply With Quote
      #2  
    Old 11-22-2009, 08:00 PM
    metropolitica metropolitica is offline
    Registered User
     
    Join Date: Nov 2009
    Location: Toronto, Ontario, Canada
    Posts: 4
    I've realized the problem is with the CSS. Once I have the final CSS, I'll post it here as [resolved].
    Reply With Quote
      #3  
    Old 11-22-2009, 08:29 PM
    metropolitica metropolitica is offline
    Registered User
     
    Join Date: Nov 2009
    Location: Toronto, Ontario, Canada
    Posts: 4
    Okay, so it ended up being the border on the ".accordion dd". I dunno why, but everything is fine without it. I had put it there to properly separate an open accordion item with the closed one below it, but it isn't needed as the open item has a faint background color, and the heading below it has none.
    Reply With Quote
    Reply

    Bookmarks

    Tags
    javascript


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 03:45 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.