Copied to clipboard

Flag this post as spam?

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


  • Molly 94 posts 134 karma points
    May 08, 2013 @ 13:42
    Molly
    0

    Identifying xslt value-of select in jquery to add a space between two classes

    Hi There 

    I am using a query filter system to filter projects by type. The jquery is using the class to identify and match the project to its group when the group name is clicked. The jquery is finding any spaces between the project names and replacing with a - in order for them to display. The client wants to be able to use a checkbox to select other categories for it to filter into so i've added a check box data type and added my categories to that, i've then used concat in the value-of select 

     <xsl:for-each select="$currentPage/ProjectGroupPage/ProjectItem">
          <xsl:element name="li"><xsl:attribute name="class"><xsl:value-of select="concat(../@nodeName,otherCats)" /></xsl:attribute>       

    This is bringing out the list correctly with the checkbox prevalues however it won't put a space inbetween the nodeName class and the otherCats classes as i'm using jquery .replace for spaces. Is there a way i can target this one space without affecting the other parts.

    Here is the jquery 

    $(document).ready(function({
      $('ul#filter a').click(function({
        $(this).css('outline','none');
        $(this).text().replace(/\s+/g,"-");
        $('ul#filter .current').removeClass('current');
        $(this).parent().addClass('current');
       
        var filterVal $(this).text().replace(/\s+/g,"-");
            
        if(filterVal == 'All'{
          $('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
        else {
          
          $('ul#portfolio li').each(function({
            if(!$(this).hasClass(filterVal){
              $(this).fadeOut('slow,linear').addClass('hidden');
            else {
              $(this).fadeIn('slow.linear').removeClass('hidden');
            }
          });
        }
        
        return false;
      });
      $('ul#portfolio li[class]').attr('class'function(iv){
       return v.replace(/\s+/g,"-").replace(/\,/g,' ');
      });
      
    });

     

    Any help would be greatly appreciated. Thanks

    Molly

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 08, 2013 @ 21:35
    Jan Skovgaard
    0

    Hi Molly

    Not sure if I'm missing anything but would'nt it help if you simply add a space in this line?

    <xsl:value-of select="concat(../@nodeName,' ',otherCats)" />

    /Jan

  • Molly 94 posts 134 karma points
    May 09, 2013 @ 15:00
    Molly
    0

    Thanks Jan, i've already tried that however the jquery function is replacing the space with - 

    I was hoping there would be a way to identify the xslt "otherCats" value in the jquery to target a space. 

     

    Thank you 

Please Sign in or register to post replies

Write your reply to:

Draft