larrysanders
01-18-2011, 01:56 PM
1) Script Title: Accordion
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ddaccordion.htm
3) Describe problem: I'm trying to modify the script to go to an anchor when one of the headers is fully expanded. So far I've succeeded in doing this BEFORE the content is done expanding, however I'd like the div to be fully expanded before the script goes to the anchor. I have no objection to a timer, however when I tried this nothing happened (see the comented code).
expandit:function($targetHeader, $targetContent, config, useractivated, directclick, skipanimation){
var ajaxinfo=$targetHeader.data('ajaxinfo')
if (ajaxinfo){ //if this content should be fetched via Ajax
if (ajaxinfo.status=="none" || ajaxinfo.status=="loading")
this.ajaxloadcontent($targetHeader, $targetContent, config, function(){ddaccordion.expandit($targetHeader, $targetContent, config, useractivated, directclick)})
else if (ajaxinfo.status=="cached"){
$targetContent.html(ajaxinfo.cacheddata)
ajaxinfo.cacheddata=null
ajaxinfo.status="complete"
}
}
this.transformHeader($targetHeader, config, "expand")
$targetContent.slideDown(skipanimation? 0 : config.animatespeed, function(){
config.onopenclose($targetHeader.get(0), parseInt($targetHeader.attr('headerindex')), $targetContent.css('display'), useractivated)
if (config.postreveal=="gotourl" && directclick){ //if revealtype is "Go to Header URL upon click", and this is a direct click on the header
var targetLink=($targetHeader.is("a"))? $targetHeader.get(0) : $targetHeader.find('a:eq(0)').get(0)
if (targetLink) //if this header is a link
setTimeout(function(){location=targetLink.href}, 200) //ignore link target, as window.open(targetLink, targetLink.target) doesn't work in FF if popup blocker enabled
}
})
function gotohash(thehash)
{
window.location.hash=thehash;
}
var thehash = config.headerclass+$targetHeader.attr('headerindex');
gotohash(thehash); //this works but does it as the div is expanding
// setTimeout(gotohash(thehash)", 500); //when this code isn't commented, is does nothing, I assume something changes where that function is no longer available after the time has passed
},
Any help would be greatly appreciated.
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ddaccordion.htm
3) Describe problem: I'm trying to modify the script to go to an anchor when one of the headers is fully expanded. So far I've succeeded in doing this BEFORE the content is done expanding, however I'd like the div to be fully expanded before the script goes to the anchor. I have no objection to a timer, however when I tried this nothing happened (see the comented code).
expandit:function($targetHeader, $targetContent, config, useractivated, directclick, skipanimation){
var ajaxinfo=$targetHeader.data('ajaxinfo')
if (ajaxinfo){ //if this content should be fetched via Ajax
if (ajaxinfo.status=="none" || ajaxinfo.status=="loading")
this.ajaxloadcontent($targetHeader, $targetContent, config, function(){ddaccordion.expandit($targetHeader, $targetContent, config, useractivated, directclick)})
else if (ajaxinfo.status=="cached"){
$targetContent.html(ajaxinfo.cacheddata)
ajaxinfo.cacheddata=null
ajaxinfo.status="complete"
}
}
this.transformHeader($targetHeader, config, "expand")
$targetContent.slideDown(skipanimation? 0 : config.animatespeed, function(){
config.onopenclose($targetHeader.get(0), parseInt($targetHeader.attr('headerindex')), $targetContent.css('display'), useractivated)
if (config.postreveal=="gotourl" && directclick){ //if revealtype is "Go to Header URL upon click", and this is a direct click on the header
var targetLink=($targetHeader.is("a"))? $targetHeader.get(0) : $targetHeader.find('a:eq(0)').get(0)
if (targetLink) //if this header is a link
setTimeout(function(){location=targetLink.href}, 200) //ignore link target, as window.open(targetLink, targetLink.target) doesn't work in FF if popup blocker enabled
}
})
function gotohash(thehash)
{
window.location.hash=thehash;
}
var thehash = config.headerclass+$targetHeader.attr('headerindex');
gotohash(thehash); //this works but does it as the div is expanding
// setTimeout(gotohash(thehash)", 500); //when this code isn't commented, is does nothing, I assume something changes where that function is no longer available after the time has passed
},
Any help would be greatly appreciated.