2012-08-14 110 views
0

我正在使用jQuery插件RhinoSlider并且它工作正常,但是我想通过AJAX加载内容以加快页面加载时间。根据他们的网站,你需要改变通话每一点为:http://rhinoslider.com/tricks/get-the-content-of-the-slider-via-ajax/通过AJAX加载jQuery插件RhinoSlider内容

默认电话是:

$(document).ready(function(){ 
    // store the jquery object 
    var $slider = $('#slider'); 
    $.get('content-of-slider.php', function(data){ 
     $slider.append(data).rhinoslider(); 
    }); 
}); 

这工作正常,但我仍然需要包括我的选择,我试过以下,但它没有工作..

$(document).ready(function(){ 
    // store the jquery object 
    var $slider = $('#slider'); 
    $.get('content-of-slider.php', function(data){ 
     $slider.append(data).rhinoslider(
      showTime: 6000, 
      effectTime: 2500, 
      autoPlay: true, 
      showBullets: 'always', 
      showControls: 'never', 
      slidePrevDirection: 'toRight', 
      slideNextDirection: 'toLeft'    
     ); 
    }); 
}); 
+0

将追加和rhinoslider拆分为2个不同的电话 – Archer 2012-08-14 10:00:58

+0

@Archer请你解释一下怎么做?我不是一个很大的JS版本,我尝试的两件事情都没有奏效。 – Brett 2012-08-15 14:20:32

+0

@Archer Scratch that ...只是注意到上面的代码缺少一些花括号,补充说,它的工作。 – Brett 2012-08-15 14:25:07

回答

1

看来我是错过了rhinoslider(部分之后的花括号;我将它们添加到下面,它现在可以工作。

$(document).ready(function() { 
    // store the jquery object 
    var $slider = $('#slider'); 
    $.get('content-of-slider.php', function(data){ 
     $slider.append(data).rhinoslider({ 
      showTime: 6000, 
      effectTime: 2500, 
      autoPlay: false, 
      showBullets: 'always', 
      showControls: 'never', 
      slidePrevDirection: 'toRight', 
      slideNextDirection: 'toLeft' 
     }); 
    });   
});