1

我正在使用带有 ajax 的 Liquid Slider,但我遇到了高度问题。

这是我的脚本:

var api2 = $.data( $('#slider-7')[0], 'liquidSlider');

  $.ajax({
    完成:函数(){

      $('#siteloader').html('这个 JSON 请求是伪造的,你肯定想在它的地方写一个真实的' + $('.profile').html()).load( 'work1.html');
      $('#siteloader2').html('这个 JSON 请求是伪造的,你肯定想在它的地方写一个真实的' + $('.profile').html()).load( 'work2.html');
      $('#siteloader3').html('这个 JSON 请求是伪造的,你肯定想在它的地方写一个真实的' + $('.profile').html()).load( 'work3.html');
      $('#siteloader4').html('这个 JSON 请求是伪造的,你肯定想在它的地方写一个真实的' + $('.profile').html()).load( 'work4.html');
      api2.adjustHeight(true, api2.getHeight());

    }

  });

页面已加载到 div 中,但 adjustHeight 无法正常工作……问题出在哪里?

谢谢

4

2 回答 2

0

为我解决的问题:

<pre>



$.ajax({
    complete: function() {
      $('#siteloader').html('<div#siteloader>This JSON request was faked, and you will surely want to write a real one in it\'s place</div>' + $('.profile').html()).load('work1.html');
      $('#siteloader2').html('<div#siteloader>This JSON request was faked, and you will surely want to write a real one in it\'s place</div>' + $('.profile').html()).load('work2.html');
      $('#siteloader3').html('<div#siteloader>This JSON request was faked, and you will surely want to write a real one in it\'s place</div>' + $('.profile').html()).load('work3.html');
      $('#siteloader4').html('<div#siteloader>This JSON request was faked, and you will surely want to write a real one in it\'s place</div>' + $('.profile').html()).load('work4.html'); 


     setTimeout(function() { 

      var api2 = $.data( $('#slider-7')[0], 'liquidSlider');

          if($().liquidSlider) {
             api2.adjustHeight(true, api2.getHeight());
          }

      }, 200); 
    }
  });

</pre>

我检查 setTimeout(function() 和“api2.adjustHeight(true, api2.getHeight());”中是否存在液体滑块功能。

感谢大家!

于 2013-09-07T16:37:04.607 回答
0

这样,只需将此脚本添加到您的 ajax 完整函数中:

var innerHeight = $('#innerElement').height();

看看那个JSFIDDLE 例子

所以......你可以像这样使用这个代码:

  $.ajax({
    complete: function() {
  $('#siteloader').html('This JSON request was faked, and you will surely want to write a real one in it\'s place' + $('.profile').html()).load('work1.html');
  $('#siteloader2').html('This JSON request was faked, and you will surely want to write a real one in it\'s place' + $('.profile').html()).load('work2.html');
  $('#siteloader3').html('This JSON request was faked, and you will surely want to write a real one in it\'s place' + $('.profile').html()).load('work3.html');
  $('#siteloader4').html('This JSON request was faked, and you will surely want to write a real one in it\'s place' + $('.profile').html()).load('work4.html');
  api2.adjustHeight(true, $(api2).height());
    }
});

希望这有帮助。

于 2013-09-05T18:52:01.640 回答