2010-11-16 21 views
0

Bonjour, je l'ai trouvé dans jscrollpane mais je n'arrive pas à comprendre comment activer le premier onglet et il ne montre pas les informations avant d'avoir cliqué. Je sais quel code je dois le mettre i juste ne sais pas où ou ce que je dois prendre pour le faire fonctionnerActivation du premier onglet à l'aide de jscrollpane

$ (function() { // Création des "onglets" $ (». Tabs «) .Chaque ( function() {

var currentTab, ul = $(this); 
    $(this).find('a').each(
    function(i) 
    { 
    var a = $(this).bind(
    'click', 
    function() 
    { 
     $("ul.tabs li:first").addClass('active').show(); 
     if (currentTab) { 
     ul.find('a.active').removeClass('active'); 

     $(currentTab).hide(); 
     } 
     currentTab = $(this).addClass('active') 
      .attr('href'); 
     $(currentTab).show().jScrollPane(); 
     return false; 
    } 
    ); 
    $(a.attr('href')).hide(); 

    } 

); 
} 
); 

});.

Répondre

0

Vous pouvez simplement déclencher un clic sur le premier lien trouvé par exemple

$('.tabs').each(
    function() 
    { 
     var currentTab, ul = $(this); 
     $(this).find('a').each(
      function(i) 
      { 
       var a = $(this).bind(
        'click', 
        function() 
        { 
         if (currentTab) { 
          ul.find('a.active').removeClass('active'); 
          $(currentTab).hide(); 
         } 
         currentTab = $(this).addClass('active') 
             .attr('href'); 
         $(currentTab).show().jScrollPane(); 
         return false; 
        } 
       ); 
       $(a.attr('href')).hide(); 
      } 
     ); 
    } 
).first().find('a').trigger('click'); 

(notez les changements sur la dernière ligne)

2
$('.tabs').each(
    function() 
    { 
     var currentTab, ul = $(this); 
     $(this).find('a').each(
      function(i) 
      { 
       var a = $(this).bind(
        'click', 
        function() 
        { 
         if (currentTab) { 
          ul.find('a.active').removeClass('active'); 
          $(currentTab).hide(); 
         } 

         currentTab = $(this).addClass('active') 
             .attr('href'); 
         $(currentTab).show().jScrollPane({ 
             showArrows: true, 
             verticalGutter: 10, 
             animateScroll: true, 
             verticalDragMinHeight: 34, 
             verticalDragMaxHeight: 34 
         }); 
         return false; 
        } 
       ); 
       $(a.attr('href')).hide(); 
      } 
     ); 
    } 
).find('a:first').trigger('click'); 

En utilisant ('a:first') au lieu de .first() a fonctionné pour moi.