2012-11-08 38 views
0

我用在我的网页下面的代码,以重新初始化JScrollPane中,对于刷新它是通过AJAX内容的DIV:不能重新初始化JScrollPane的(使用Ajax)

<script> 
    var $j = jQuery.noConflict(); 
    $j(document).ready(function() { 

     $j('#map_data').jScrollPane({ 
       showArrows: true, 
       autoReinitialise: false 
     }); 

     $j('.country .point').click(function() { 
      var point_id = $j(this).attr('id'); 
      theCall(point_id); 
     }); 

    }); 

    function theCall(pointid) { 
     $j.ajax({ 
      type: 'POST', 
      url: 'my_ajax_receiver.php', 
      data: {point_id: pointid}, 
      dataType: 'html',  

      success: function(a) { 
          $j("#map_data").html(a); 

          var api = $j("#map_data").jScrollPane().data('jsp'); 
          api.getContentPane().html(a); 
          api.reinitialise(); 
      } 

     }); 
    } 
</script> 

我搜索和测试许多其他解决方案建议关于这个问题,但到现在为止没有任何工作在这段代码中我没有看到任何错误。有人能帮助我吗?

回答

0

不知怎的,它的工作现在,这是正确的代码,它可以帮助别人

<script> 
    var $j = jQuery.noConflict(); 
    $j(document).ready(function() { 

     $j('.country .point').click(function() { 
      var point_id = $j(this).attr('id'); 
      theCall(point_id); 
     }); 

    }); 

    function theCall(pointid) { 
     $j.ajax({ 
      type: 'POST', 
      url: 'my_ajax_receiver.php', 
      data: {point_id: pointid}, 
      dataType: 'html',  

      success: function(a) { 
          $j("#map_data").html(a); 

          var api = $j('#map_data').jScrollPane({}).data('jsp'); 
          api.reinitialise(); 
      } 

     }); 
    } 
</script>