0

因此,在我的 div 上加载了一些内容后,我想初始化 jscrollpane,但它不起作用。这是我的代码。看看你们能不能告诉我什么是错的。

阿贾克斯(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
          },
        });

    });

它现在可以工作了!

4

2 回答 2

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
      },
    });

});
于 2012-02-23T19:12:18.097 回答
0

它可能与淡入淡出动画有关。我不认为 jScrollPane 可以在动画时测量内容。至少这是我的猜测。

试试这个:

$("#cargaContenido").html(x).fadeIn(500, function() {
    //Callback when the fadeIn is complete
    $('#cargaContenido').jScrollPane();
});
于 2012-02-23T19:16:40.413 回答