简体   繁体   English

在提供淡入淡出效果后显示选项卡的内容

[英]showing content of tab after giving fade effect

In my page there are a number of tabs and I want to show the content of tab by giving fade effect. 在我的页面中,有许多选项卡,我想通过提供淡入淡出效果来显示选项卡的内容。 In order to do this I need the tab divs which has a class name of sectionContent after fade function to be style="display:block". 为了做到这一点,我需要在淡入淡出功能后具有类名称sectionContent的选项卡div为style =“ display:block”。 However when I look at them from firebug it is shown as for example: 但是,当我从萤火虫看它们时,例如:

<div id="lesson-grammar" class="sectionContent" style=""> 

and so the tab is not shown. 因此该标签未显示。 How can I do that? 我怎样才能做到这一点? thanks a lot. 非常感谢。

new Ajax.Request(ajaxUrl,
  {
     method:'post',
     onSuccess: function(data){         
         var tmp=data.responseText;
         $$('.exercise-main .content').invoke('insert',tmp);
         $$('.exercise-main .sectionContent').invoke('setStyle','display:none');

         $('lesson-'+tab).fade({
             from:0,
             to:1,
             afterFinish: function(){
              //do the job                                     
             }
         });

     }
 });

<div class="exercise-main">
  <div class="content">
    <div id="lesson-discussion" class="sectionContent">  
     ...
    </div>
    <div id="lesson-grammar" class="sectionContent">  
     ...
    </div>
    <div id="lesson-dialogue" class="sectionContent">  
     ...
    </div>
   </div>
</div>

I believe your style declaration is not in the right syntax. 我认为您的样式声明语法不正确。 Try this: 尝试这个:

$$('.exercise-main .sectionContent').invoke('setStyle',{display: "none"});

Let me understand your problem first, from your code and your explanation. 让我首先从您的代码和说明中了解您的问题。

What you want to achieve is hiding all the tabs after the ajax response arrives, insert the response into a new tab, then display it with a fade in effetct? 您要实现的是在ajax响应到达后隐藏所有选项卡,将响应插入新选项卡,然后在effetct中淡入显示?

If this is your desire, then you probably have a selector problem. 如果这是您的愿望,那么您可能会遇到选择器问题。 You are using $$ selectors except for one place: 您正在使用$$选择器,但以下位置除外:

$('lesson-'+tab).fade({...

I think this is the problem. 我认为这是问题所在。 Does your firefox/chrome console show any problems? 您的firefox / chrome控制台是否显示任何问题? What if you try to run this: 如果您尝试运行此命令怎么办:

$('lesson-'+tab)

What does happen? 会发生什么? Do you see the proper HTML element logged into the console? 您是否看到正确的HTML元素登录到控制台?

Try these, then let me know the result and I will try to help. 试试这些,然后让我知道结果,我将尽力提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM