I am trying to filter a foreach in an xslt by a class.
In content I have the following nodes: swatches, blankets, signs, decals. I am using a drop down to display the node, then using jQuery I am setting a class="selected" on the chosen node. I wish to display it's child nodes in a separate text area.
I can display all of the child nodes for each of the parent nodes using this for-each:
The top section is displaying the parent nodes: Swatches, Blankets, Hangtags, Posters, etc. Then I'm setting the class on the <span> to "selected" onclick.
The bottom is displaying the child nodes for every parent. This is where I want to limit to only show the nodes where the class is selected.
Thank you for your response! Thanks for clarifying that for me also. I didn't know if it was possible to have those"talk" to each other. I will be looking into what you suggested. I have never done anything like this before. The "selected" class is an attribute not a childnode.
Filtering Foreach by class
I am trying to filter a foreach in an xslt by a class.
In content I have the following nodes: swatches, blankets, signs, decals. I am using a drop down to display the node, then using jQuery I am setting a class="selected" on the chosen node. I wish to display it's child nodes in a separate text area.
I can display all of the child nodes for each of the parent nodes using this for-each:
<xsl:for-each select="$currentPage/OrderGroup/OrderItem">
However I can not filter by the "selected" class.
Is there a way I can capture the Id of the node in jQuery and filter by that Id in the other text area?
Hi Eric
Could you show us the code you have so far?
/Jan
<label for="file" class="label"><h4><b>Category</b></h4>
<span class="selectMultiple multiple anthracite-gradient replacement" style="width:200px" tabindex="0"><span class="drop-down">
<xsl:for-each select="$currentPage/OrderGroup">
<xsl:choose>
<xsl:when test="position() = 1">
<span class="listing selected"><xsl:value-of select="@nodeName"/></span>
</xsl:when>
<xsl:otherwise>
<span class="listing"><xsl:value-of select="@nodeName"/></span>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</span>
</span>
</label>
<div class="field-block button-height" style="margin-top:auto;">
<h4><b>Item</b></h4>
<span class="selectMultiple multiple anthracite-gradient replacement" style="width:650px" tabindex="0">
<span class="drop-down">
<xsl:for-each select="$currentPage/OrderGroup/OrderItem">
<span class=""><xsl:value-of select="@nodeName"/></span>
</xsl:for-each>
</span>
</span>
</div>
</div>
The top section is displaying the parent nodes: Swatches, Blankets, Hangtags, Posters, etc. Then I'm setting the class on the <span> to "selected" onclick.
The bottom is displaying the child nodes for every parent. This is where I want to limit to only show the nodes where the class is selected.
Hi Eric,
Just to clarify: XSLT happens on the server — jQuery happens in the browser.
To have those "talk" to each other, they'll need to leave a trail behind for the other to pickup...
From XSLT you can set a data-attribute on the element in question, which jQuery can read.
From the browser you'll need to either set a cookie, or put a parameter in the page's QueryString (both require a new request)
How is the "selected" class available on the OrderItem elements? Is it a separate childnode, or an attribute?
/Chriztian
Chriztian,
Thank you for your response! Thanks for clarifying that for me also. I didn't know if it was possible to have those"talk" to each other. I will be looking into what you suggested. I have never done anything like this before. The "selected" class is an attribute not a childnode.
Eric
is working on a reply...