2012-08-02 52 views
1

我一直在研究這段代碼。我試圖在圖庫頁面加載ajax後實現SmoothDivScroll jquery插件。這是我的js與ajax。請注意,smoothdivscroll工作正常,無需使用ajax加載圖庫。jquery插件在ajax載入頁面時未加載

$(document).ready(function(){ 

    $('.more').live('click',function(){ 
     var href = $(this).attr('href'); 
     if ($('#ajax').is(':visible')) { 
      $('#ajax').css('display','block').animate({height:'1px'}).empty(); 
     } 
     $('#ajax').css('display','block').animate({height:'380px'},function(){ 
      $('#ajax').html('<img class="loader" src="images/loader.gif" alt="">'); 
      $('#ajax').load('content.php #'+href, function(){ 
       $('#ajax').hide().fadeIn().highlightFade({color:'#717171'}); 
      }); 
     }); 
     return true; 
    }); 

    $("div#makeMeScrollable").smoothDivScroll({ 
     mousewheelScrolling: true, 
     manualContinuousScrolling: true, 
     visibleHotSpotBackgrounds: "always", 
     autoScrollingMode: "onstart" 
    }); 

}); 

更新:雖然@Mathletics答案的確得到了插件調用它的回調來加載,該smoothscrollingdiv並不那麼順利。圖片不內聯,滑動非常不平穩。它工作得很好,無需通過ajax加載它。下面我提供了它與ajax和沒有的相似的鏈接。

阿賈克斯加載:select gallery from the menu

沒有阿賈克斯:This is how the gallery is supposed to be

回答

1

移動電話smoothDivScroll到您的回調。

$(document).ready(function(){ 

    $('.more').live('click',function(){ 
     var href = $(this).attr('href'); 
     if ($('#ajax').is(':visible')) { 
      $('#ajax').css('display','block').animate({height:'1px'}).empty(); 
     } 
     $('#ajax').css('display','block').animate({height:'380px'},function(){ 
      $('#ajax').html('<img class="loader" src="images/loader.gif" alt="">'); 
      $('#ajax').load('content.php #'+href, function(){ 
       $('#ajax').hide().fadeIn().highlightFade({color:'#717171'}); 
        $("div#makeMeScrollable").smoothDivScroll({ 
        mousewheelScrolling: true, 
        manualContinuousScrolling: true, 
        visibleHotSpotBackgrounds: "always", 
        autoScrollingMode: "onstart" 
       }); 

      }); 
     }); 
     return true; 
    }); 


}); 
+0

插件加載,但無法正常滾動。 – user1165309 2012-08-02 18:24:26

相關問題