-3

I am working with a template I purchased and am trying to add functionality to a tab block. The template can be viewed here. http://themeforest.net/item/developr-fully-responsive-admin-skin/full_screen_preview/2085628 . I am using the "Side Tabs" and am dropping in images into the empty content area in the tabs block. The first tab I have is going to be an "All" tab that shows several images, all of which will have a corresponding tab.

What I want to do is have it where I click any of the images in the "All" tab and the corresponding tab opens. The template is set up so that when a user clicks a tab it sets that tab to active. I want to do this same thing but instead of clicking on the tab, I want to be able to click on the corresponding image. I hope I am explaining clear enough. I was thinking I could either programatically trigger an onClick event on the tab when I click the image or I could set the class to active on the tab when I click the image.

  <!-- Tabs -->
    <ul class="tabs">
        <li class="active">
            <a href="#sidetab-all">All</a>
        </li>
        <xsl:for-each select="$currentPage/SKUContainer/SKU">
            <li>
                <a href="#sidetab-{position()}"><xsl:value-of select="./productNumber"/> - <xsl:value-of select="./productName"/></a>
            </li>
        </xsl:for-each>
    </ul>

    <!-- Inside each tab -->
    <div class="tabs-content" style="min-height: 194px;"> 
      <!--Display SKU images --> 
        <div class="with-padding" style="min-height: 190px; margin-bottom:10px;"    id="sidetab-all">

    <xsl:for-each select="$currentPage/SKUContainer/SKU">
      <div class="with-padding" style="width:190px; list-style:none; text-align:center; margin:0px; padding:0px; float:left;">

      <div style="background:#333333;">
                      <a href="#sidetab-{position()}"><img style="margin:0px;padding:0px; background:#666;" src="{umbraco.library:GetMedia(./mainImage, 'false')/umbracoFile}"/></a>

                      <div style="text-align:center; list-style:none; width:190px; background:#333; color:white; padding: 0px 0px 1px 0px; font-size: 12px;"><xsl:value-of select="productNumber"/> - <xsl:value-of select="productName"/></div>
                      <div style="text-align:center; list-style:none; width:190px; background:#333; color:white; padding: 0px 0px 5px 0px; font-size: 12px;"> <xsl:value-of select="width"/> x <xsl:value-of select="height"/> x <xsl:value-of select="depth"/></div>
                    </div>
                  </div>
                </xsl:for-each>

              </div>

 <xsl:for-each select="$currentPage/SKUContainer/SKU">
   <div class="with-padding" style="min-height: 190px;" id="sidetab-{position()}">
     <div style="float:left;">
       <xsl:if test="./mainImage &gt; 0">
         <img src="{umbraco.library:GetMedia(./mainImage, 'false')/umbracoFile}"/> 
       </xsl:if>
     </div>  

 <!--Display SKU name -->       
   <div class="with-padding" style="float:left;">
     <h3><xsl:value-of select="./productName"/></h3>
   </div> 

 <!--Display Content -->
   <div class="with-padding" style="float:left;">
     <xsl:value-of select="bodyText" disable-output-escaping="yes"/>
   </div>

   <div style="clear:left;"></div>
 </div>
</xsl:for-each>

</div>
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Eric
  • 39
  • 1
  • 10
  • 2
    http://www.whathaveyoutried.com – Jay Blanchard Dec 19 '12 at 19:40
  • A screenshot with markings indicating the various areas you are talking about would be extremely helpful. Put another way a picture is worth a 1000 words. – ahsteele Dec 19 '12 at 19:41
  • I don't have enough of a reputation to post images yet. – Eric Dec 19 '12 at 20:00
  • 1
    Two links for you: http://stackoverflow.com/questions/155188/trigger-a-button-click-with-javascript-on-the-enter-key-in-a-text-box and http://bit.ly/URFmhh – Dan Crews Dec 19 '12 at 20:09
  • I have researched this but couldn't find any examples similar... Thanks for the people that are helping. @DanCrews – Eric Dec 19 '12 at 20:17

2 Answers2

0

Try... ?!

jQuery(document).ready(function() {
    var $tab = jQuery('.tab-selector');
    $tab.trigger('click');
});
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
algorhythm
  • 8,530
  • 3
  • 35
  • 47
  • I just added my code. Thanks for the help I really appreciate it!! – Eric Dec 19 '12 at 20:36
  • I did. It got me going the right direction. I posted my code that accomplished what I was trying for. Thank you for your time and guidance! – Eric Dec 20 '12 at 18:57
0
  <script type="text/javascript">
    $(function(){
      $('.sidetabimage').click(function(e){
        e.preventDefault();
        var idName = $(this).attr("id");
        var id = idName.replace("sidetabimage-","");
        $('#sidetabnav-'+id).click();
      });
    });
  </script>

^^ This worked for me. Thanks for the links and advice everyone!

Eric
  • 39
  • 1
  • 10