• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 284
  • Last Modified:

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?
0
Monika Arturi
Asked:
Monika Arturi
  • 9
  • 7
1 Solution
 
Michel PlungjanIT ExpertCommented:
try something like

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

0
 
Monika ArturiAuthor Commented:
Thank you!!!!!!!!!!!!!!!!! That did it. I appreciate your help, i've bee trying to resolve this for a while. Thanks!!!
0
 
Monika ArturiAuthor Commented:
Solution delivered fast.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Michel PlungjanIT ExpertCommented:
YW :)
0
 
Monika ArturiAuthor 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 ArturiAuthor 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 ArturiAuthor 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 ArturiAuthor 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 ArturiAuthor 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 ArturiAuthor 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 ArturiAuthor 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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 9
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now