2012-02-23 88 views
0

所以在我的div上加載了一些內容之後,我想初始化jscrollpane,但它不起作用。這是我的代碼。看看你們是否能告訴我什麼是錯的。JScrollpane不會在ajax後工作

阿賈克斯(jQuery的)

$("#mision").click(function() { 
     var id = this.id; 
     $.ajax({ 
      url: template + "/acciones.php", 
      type: "POST", 
      data: "id=" + id, 

      complete: function() { 

      }, 

      success: function(x) { 
      $("#cargaContenido").html(x); 
       $("#scrollpro").css({'height':(($(window).height())-361)+'px'}); 
     $('#scrollpro').jScrollPane({ 

     }); 

     $(window).resize(function(){ 
      $('#scrollpro').css({'height':(($(window).height())-301)+'px'}); 
      $('#scrollpro').jScrollPane({autoReinitialise: true}); 
     }); 
       $("#scrollpro").trigger('resize'); 

     }, 

      error: function() { 
      //called when there is an error 
      }, 
     }); 

    }); 

現在做的工作!

回答

2

試試這個:

$("#mision").click(function() { 
    var id = this.id; 
    $.ajax({ 
     url: template + "/acciones.php", 
     type: "POST", 
     data: "id=" + id, 

     complete: function() { 
     $('#cargaContenido').jScrollPane().fadeIn(); 
     }, 

     success: function(x) { 
     $("#cargaContenido").html(x); 

    }, 

     error: function() { 
     //called when there is an error 
     }, 
    }); 

}); 
+0

仍然不工作:/ – Buff 2012-02-23 19:17:41

+0

嘗試做淡入創建JScrollPane的後 – 2012-02-23 19:25:17

+0

呀它不工作尚未:/ – Buff 2012-02-23 19:30:15

0

它可能有一些做的淡入動畫。我不認爲jScrollPane可以在動畫時測量內容。至少這是我的猜測。

試試這個:

$("#cargaContenido").html(x).fadeIn(500, function() { 
    //Callback when the fadeIn is complete 
    $('#cargaContenido').jScrollPane(); 
}); 
+0

尚未:/仍然不工作 – Buff 2012-02-23 19:35:01

+0

我編輯我的問題仍然沒有運氣甚至沒有API的東西:/ – Buff 2012-02-23 19:57:02