Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rachel Skuse 88 posts 118 karma points
    Oct 31, 2011 @ 14:16
    Rachel Skuse
    0

    Using jQuery in XSLT

    Hi,

    This may be more of a jQuery question but I am essentially using XSLT to try and do what I need to do!

    Basically, I have an accordian menu which opens/ closes when you select an item and I want to be able to link to different accordian items from another page... So, I click a link and it takes me to the accordian page with the specific accordian item open - I have assigned each accordian item a unique id but I need to also update the class so that the item is open - this is where I am stuck!

    My xslt is simple...

        <xsl:variable name="linkID" select="$currentPage/data [@alias = 'linkID']" />

        <xsl:if test="$currentPage/data [@alias = 'linkID'] != ''">
            <a href="/accordian.aspx?t=t{$linkID}" id="addclass">Read this Item</a>
        </xsl:if>

    Now, I'm not too familiar with jQuery but I think I can do something similar to this...

        <![CDATA[
          $("#addClass").click(function () {
          $('li').addClass('activeacitem');
          });
          ]]>

    What I am trying to achieve is that the <li> of the accordian item has a class of 'activeitem' added to it but this needs to pass through the link!

    Sorry if this is a little confusing :)

    Thanks,
    Rach

  • Darryl Godden 145 posts 197 karma points
    Oct 31, 2011 @ 14:27
    Darryl Godden
    0

    Hi Rachel,

    I've done something similar with jQuery, but hiding and opening DIV's created by the XSLT. My XSLT is this:

      <div id="our-brands-info-block">
        <xsl:for-each select="$currentPage/descendant::* [@isDoc]">
          <div id="{ucomponents.strings:StripWhitespace(@nodeName)}">

    Then in jQuery:

    if ($.QueryStringExist({ ID: "brand" })) {
                  var bd = $.getQueryString({ ID: "brand" });
                  $('#' + bd).trigger('click');
    $("#amplify").click(function () {
                  hideAll();
                  $("#Amplify").fadeIn('fast');
                  removeSelectedButton();
                  addSelection(this);
              });

    That's it in a nutshell, but if you need me to expand further please say so.

  • Rachel Skuse 88 posts 118 karma points
    Oct 31, 2011 @ 14:45
    Rachel Skuse
    0

    Thanks Darryl, it looks a little advanced for me but I'll have a play around with your code and see what I can achieve! :)

  • Darryl Godden 145 posts 197 karma points
    Oct 31, 2011 @ 14:47
    Darryl Godden
    0

    No worries, Just to follow up - I'm using a jQuery plug-in (jQueryString) to read the querystring which triggers the open on the appropriate content.

Please Sign in or register to post replies

Write your reply to:

Draft