How can I link an accordion header to a URL as well as expand

I'm using the jquery accordion (http://jqueryui.com/demos/accordion/).
i would like to have the <h3> headers not only click to expand the accordion section, but to link to a page at the same time.
I've tried various solutions offered here in the posts and just as for others, they did not work. Could anyone offer a solution that has worked?
Monika ArturiOwner, Designer, and DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michel PlungjanIT ExpertCommented:
try something like

$(document).ready(function() {
  $(".ui-accordion-header").live('click', function() {
    window.open($(this).find("a").attr("href"),"blank")
  });
});

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Monika ArturiOwner, Designer, and DeveloperAuthor Commented:
Thank you!!!!!!!!!!!!!!!!! That did it. I appreciate your help, i've bee trying to resolve this for a while. Thanks!!!
0
Monika ArturiOwner, Designer, and DeveloperAuthor Commented:
Solution delivered fast.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Michel PlungjanIT ExpertCommented:
YW :)
0
Monika ArturiOwner, Designer, and DeveloperAuthor Commented:
Just a follow up, how would I go about preventing this header URL to open in a new window. i did replace "blank" with "self" or "parent" and neither did the trick.

<script type="text/javascript">
      $(function(){
        // Accordion
        $("#accordion").accordion({ header: "h3", active: activeNode, alwaysOpen: true, autoHeight: false });
        $(document).ready(function() {
  $(".ui-accordion-header").live('click', function() {
    window.open($(this).find("a").attr("href"),"self")
  });
});
      });
    </script>
0
Michel PlungjanIT ExpertCommented:
_self or _top but then the page will be overwriiten with the new one so what is the point ?
0
Monika ArturiOwner, Designer, and DeveloperAuthor Commented:
Trying to send you private message with a link to show you. The site's not live so i don't want to paste it here. Now I just need the accordion to remain open on the landing page.
0
Monika ArturiOwner, Designer, and DeveloperAuthor Commented:
sent you a message with link. let me know if you could offer a solution.i really appreciate it.
0
Michel PlungjanIT ExpertCommented:
Ok I'll look shortly
0
Michel PlungjanIT ExpertCommented:
Ok UNLESS you want to AJAX in the content, you do NOT need to accordion the header
You need to EXPAND the head of the page you are on onload

So in this case something like in the planning page

 $("#accordion").accordion({ header: "h3", active: 0, ....

and development
 $("#accordion").accordion({ header: "h3", active: 1, ....

If you need me to find a cleaner way, I can look tomorrow.

I am off to bed now
0
Monika ArturiOwner, Designer, and DeveloperAuthor Commented:
Hi,
I am unable to control this per page because I am building this into an Umbraco template. I have to add something that automatically knows which page it's on and expands the corresponding nav item. When I add the active #, as you sent, it expands only that specific one regardless of the page i am on. this used to work before with the script below but not since the new URL function was fixed.

<script type="text/javascript">
  var activeNode = -1;
</script>  
0
Michel PlungjanIT ExpertCommented:
activeNode=-1 is all collapsed

instead do


<script type="text/javascript">
  var activeNode = 0; // 0 on page 1, 1 on page 2 and so on
      $(function(){
        // Accordion
        $("#accordion").accordion({ header: "h3", active: activeNode, alwaysOpen: true, autoHeight: false });
        $(".ui-accordion-header").live('click', function() {
          location = $(this).find("a").attr("href");
        });
      });
    </script>
0
Monika ArturiOwner, Designer, and DeveloperAuthor Commented:
Previously we used a script like the below for the accordion to expand on the right page. It's in a template so i can't put a different script in each page like you suggested. it has to know automatically which section to expand based on the page it's on.

      var activeNode = <xsl:value-of select="position()" /> - 1;

When I insert it, I don't get the same results as before where the section would expand as it needed to (http://76.238.121.17:803 If you click on the different side navs, the same one continues to expand.)

<script type="text/javascript">
  var activeNode = <xsl:value-of select="position()" /> - 1;
      $(function(){
        // Accordion
        $("#accordion").accordion({ header: "h3", active: activeNode, alwaysOpen: true, autoHeight: false });
        $(".ui-accordion-header").live('click', function() {
          location = $(this).find("a").attr("href");
        });
      });
    </script>
0
Monika ArturiOwner, Designer, and DeveloperAuthor Commented:
i sent you the file that has the code for the entire xslt file used by Umbraco that houses this portion of the script. Maybe that will help to see what I'm referring to.
0
Michel PlungjanIT ExpertCommented:
I do not see the script
<script type="text/javascript">
  var activeNode = <xsl:value-of select="position()" /> - 1;

in the link you posted http://76.238.121.17:803 
0
Monika ArturiOwner, Designer, and DeveloperAuthor Commented:
It's just going to show up in that script i emailed you. Did you see it there? I'll email again and attach it as a file. if you 'view source' off the page, it won't show. it's an umbraco template. not sure if you're familiar with that but basically it's templates, stylesheets and scripts all in different directories getting pulled together.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.