PDA

View Full Version : Accordion Content Script and AJAX help



reden
04-27-2008, 10:53 AM
1) Script Title: Accordion Content Script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ddaccordion.htm

3) Describe problem:
I was successful in implementing AJAX within this script, but I need help using the available "onopenclose:function" with Accordion Content to load my specific files. Right now they're loading regardless, I need them to load upon clicking.

For example, this is what I'm using to embedd files via AJAX into an accordion content box:



<h3 class="mypetsC">Dogs</h3>
<div class="thepetC">

<div id="mainContainer">
<div class="news" id="news1"><!-- Empty div for dynamic content -->Loading news. please wait...</div>
</div>

<script type="text/javascript">
ajax_loadContent('news1','webfile.php');
</script>

</div>

Anyone can help me opening this content via the "onopenclose:function" please?

ddadmin
04-28-2008, 07:22 AM
Well, assuming ajax_loadContent() works correctly on its own, to call it only when the user explicitly opens an accordion header, you'd do something like the below inside the configuration code:


animatespeed: "fast", //speed of animation: "fast", "normal", or "slow",
onopenclose:function(header, index, state, isclicked){ //custom code to run whenever a header is opened or closed
if (state=="block" && isclicked==true){ //if header is expanded and as the result of the user clicking on it
ajax_loadContent('news1','webfile.php')
}