2012-06-20 33 views
0

我使用jQuery工具的選項卡手風琴按這裏:http://www.jquerytools.org/demos/tabs/accordion.htmjQuery的工具:等待手風琴幻燈片到結束,然後顯示在手風琴的圖像

整個事情與激活

代碼:

$("#accordion").tabs(
    "#accordion div.pane", 
    {tabs: 'h2', effect: 'slide', initialIndex: null} 
); 

雖然窗格的內容揭示了滑動功能,在我的設置,我想窗格中的圖像顯示只有一次的幻燈片動畫已經完成,加上當前選項卡的圖像應該被隱藏再一次手風琴標題被點擊。我已經擺弄,但無法使它工作。

我認爲圖像設定爲顯示的:無;然後在其他內容顯示後將其更改爲顯示?

我可以通過添加一些東西到上面的代碼做到這一點?非常感謝

回答

2

我想你會想要做一個自定義動畫。它應該非常簡單。

$.tools.tabs.addEffect("custom", function(tabIndex, done) { 

    // hide any images 
    $("#accordion img").hide(); 

    // hide all panes and show the one that is clicked, on complete show images 
    this.getPanes().hide().eq(tabIndex).show('fast',function(){ 
     //show the images again now that the animation has finished 
     $("#accordion img").show(); 
    }); 

    // the supplied callback must be called after the effect has finished its job 
    done.call(); 
    }); 

然後,您可以用'自定義'替換動畫效果'幻燈片'。

+0

謝謝,這就像一個魅力。恥辱我不能進一步投票。不幸的是,它現在不會滑動太多,即當前窗格正在崩潰,而新窗口正在擴展。否則,非常感謝! – user1154435

0

我以爲圖片設置爲顯示:無;然後將其更改爲 ,以便在顯示其餘內容後再顯示它們?

,這是我會怎麼做。顯示:在所有圖像上都不顯示,則:

$(document).ready(function() { 
    $("#accordian img").show(); 
}); 

圖像在整個文檔加載之前不會顯示。

0

如果您的意思是要打開手風琴的窗格,然後顯示其中的圖像,請查看手風琴的change事件,當窗格打開時,此事件可能會注意到您。是的,你需要將圖像設置爲首先隱藏。

0

您可以直接綁定到標籤的「負荷」事件......

$("#accordion").tabs(
    "#accordion div.pane", 
    {tabs: 'h2', effect: 'slide', initialIndex: null, 
    load: function(event, ui){ 
     $('accordian img').show(); 
    } 
    } 
); 

現在,當標籤加載完成(DOM就緒),它會顯示在div的圖像,只有在DOM has been updated to completely reflect the changes to the elements in the tab之後。