Results 1 to 8 of 8

Thread: How to get an object instance ?

  1. #1
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default How to get an object instance ?

    I'm using stickmanlabs.com's accordion and I want to get the active accordion to do some manipulation.

    I need to do something like this :
    Code:
    var activeAccordion = GetInstanceActiveAccordionOrSomewayToDoIt("AcdordionName");
    activeAccordion.activate($$('#vertical_container .accordion_toggle')[0]);
    Thank you
    GeemeeTheway

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,135
    Thanks
    44
    Thanked 3,231 Times in 3,192 Posts
    Blog Entries
    12

    Default

    Well, I'm not too sure about what would constitute the active accordion. However, if you want to access a given accordion, you would need to create it with a reference, ex:

    Code:
    var myAccordion = new accordion('#myId');
    Once you have that, you can do some things with it using other script code as shown on the demo page.

    If you want to somehow have Accordion v2.0 keep track of which of several accordions on a given page was last to be activated by the user, that would be a bit more complex. Unless the author has made some provision for it, it would require additional coding, at the very least a listener for the page.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    When I do this, I got two instances of the same object and the accordion got weird beheviors like opening container many time.

    If someone can help me make a singleton we that.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,135
    Thanks
    44
    Thanked 3,231 Times in 3,192 Posts
    Blog Entries
    12

    Default

    That sounds like you have either defined the same accordion more than once or have more than one accordion with the same variable reference. To see what's going on, I would need to see a page that demonstrates the problem:

    Please post a link to the page on your site that contains the problematic code so we can check it out.


    Please also tell me what to do on your page to get it to misbehave.

    Alternatively, you could donate five bucks to the author. It is my understanding (though I could be wrong about this) that's all it would take for him to give you this type of support in a timely manner.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Author's forum is down for now.

    I'll try to make a temporary online of this mistake soon. It's on beta version for now.

    Thanks!

  6. #6
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    here the link : http://www.plandematchcommunication.com/temporaire/

    If you click on accordion's red tabs, everything is fine. Now, click on the bottom black links to open specific tabs a few time. After, click on the red tabs again and look at the weird behevior.

    I think that is because that every time, I got a new instance when this line is proceed :
    Code:
    var bottomAccordion = new accordion('vertical_container');
    How can I open specific tab without make a new instance ?

    Geemee Theway

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,135
    Thanks
    44
    Thanked 3,231 Times in 3,192 Posts
    Blog Entries
    12

    Default

    By declaring it in the global scope to begin with:

    Code:
    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Plan de Match Communication </title>
    <meta name="description" content="Publicité, marketing, claude lussier, mise en marché, radio, tv, affaires, stratégie" />
    <meta name="keywords" content="Agence de publicité et stratégie marketing, " />
    <meta name="author" content="" />
    <base href="http://www.plandematchcommunication.com/temporaire/" />
    <link href="favicon.ico" rel="icon" type="image/x-icon" />
    
    <meta name="verify-v1" content="0rm0MfCF41YR034RbIX397YRnP1yBjNZ/cG0NwfliKU=" />
    <!-- CSS -->
    <link rel="stylesheet" type="text/css" href="css/reset.css">
    <link rel="stylesheet" type="text/css" href="css/plandematchcommunication.css">
    
    <script type="text/javascript" src="includes/prototype.js"></script>
    <script type="text/javascript" src="includes/scriptaculous.js"></script>
    <script type="text/javascript" src="includes/effects.js"></script>
    
    <link rel="stylesheet" type="text/css" href="css/accordion.css" />
    
    	<script type="text/javascript" src="includes/accordion.js"></script>
    <script type="text/javascript">
    		
    	//
    	//  In my case I want to load them onload, this is how you do it!
    	// 
    	Event.observe(window, 'load', loadAccordions, false);
    
    	//
    	//	Set up all accordions
    	//
    	var bottomAccordion;
    	function loadAccordions() {
    		bottomAccordion = new accordion('vertical_container');
    	}
    	
    	function openMe(ThisPanel) {
    		bottomAccordion.activate($$('#vertical_container .accordion_toggle')[ThisPanel]);
    		return false;		
    	}
    	
    </script>
    
    <link rel="stylesheet" type="text/css" href="css/lightwindow.css" />
    <script type="text/javascript" src="includes/lightwindow.js"></script>
    
    </head>
    <body>
    		<div class="TEAMMain" id="TEAMSite">
    			<div class="TEAMHeader">
    				<a href="#"><img class="TEAM_logo" src="images/design/logo_plandematchcommunication.png" width="269" height="58" alt="Plan de Match Communication "></a>
    			</div> <!-- TEAMHeader -->
    			
    			<div id="TEAMContent">
    
    				<div id="vertical_container" >
    
    					<div class="accordion_toggle"><h4 class="onglet1">Tab #1</h4></div>
    					<div class="accordion_content" style="background:url('images/design/contenu_back1.jpg') top left repeat-x #fbfbfc;">
    						<div style="margin:0 auto;width:960px;">
    							<p>
    								Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla non lorem sit amet augue mattis ornare. In porta, nisi sed iaculis pellentesque, arcu elit imperdiet libero, sed tincidunt risus ligula id ve 
    
    . . .
    
    
    
     . . . ntum, mauris id ultrices commodo, sem turpis sodales mauris, a bibendum augue orci sit amet orci. Integer justo enim, viverra ut, dignissim elementum, porttitor in, felis.
    							</p>
    
    						</div>
    					</div>
    
    
    				</div>	<!-- vertical_container -->			
    
    				<div class="TEAM_footer">
    					<table width="100%" border="0">
    						<tr>
    							<td valign="top">
    								<p class="TEAM_Menu"><a href="#" onclick="return openMe(0);">Toggle Tab #1</a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp; </p>
    
    								<p class="TEAM_Menu"><a href="#" onclick="return openMe(1);">Toggle Tab #2</a> &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp; </p>
    								<p class="TEAM_Menu"><a href="#" onclick="return openMe(2);">Toggle Tab #3</a></p>
    							</td>
    								
    							<td valign="top" align="right">
    															</td>
    						</tr>
    
    					</table>
    				</div> <!-- TEAM_footer -->
    
    			</div> <!-- TEAMContent -->
    			
    		</div> <!-- TEAMMain -->
    
    </body>
    </html>
    Notes: I made some other changes in your code, returning (false) onclick of the 'external toggles', for example. Mid section of page unchanged, removed in the above for brevity.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. The Following User Says Thank You to jscheuer1 For This Useful Post:

    geemeetheway (11-17-2008)

  9. #8
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Great! Thank you !

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •