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

It may have something to do with the fadeIn animation. I don't think jScrollPane can measure the content while its animated. At least it's my guess.

Try this instead:

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