views:

36

answers:

1

Hi all,

I am having a nightmare trying to get this working (and have looked at other posts but am still having an issue).

Basically I have a link like this:

/test.php#bob

on test.php I have this:

<div class="accordion">
 <h2>Customer care</h2>
 <div>
  <p>xxxxxxxxxxxxx</p>
 </div>
 <h2 id="bob">Strong leadership from start to finish</h2>
 <div>
  <p>fffffffffff</p>
 </div>
 <h2>Certainty of delivery, no matter how complex or difficult</h2>
 <div>
  <p>dddddddddd</p>
 </div>
</div>

And in jQuery I have this:

$(".accordion").accordion({
 autoHeight: false,
 collapsible: true,
 navigation: true,
 active: 'none'
});

But I still cant get the #bob panel to open via the link.

Any ideas? Im pulling my hair out.

A.

A: 

You can do it like this:

$(".accordion").accordion({
 autoHeight: false,
 collapsible: true,
 navigation: true,
 active: 'none'
});
if(location.hash) $(location.hash).click();

This would perform a click on the <h2> (by using the hash, which includes the # as an #id selector), invoking the standard accordion behavior.

Nick Craver