从ajax加载flexslider

I'm trying to load a flexslider from ajax. It works when I point directly on the page containing the slider, but from ajax the slider doesn't load.

Here is my ajax page:

$(document).ready(function(){

//Ajax Event Handler For Categorie Demo
var $menu1 = $('#navDemo02');



function success(){

    $('div.ajaxContent').hide();
  $('div.ajaxContent').show(200);
}

function ajaxCallTimeout(index){
var url = 'categorie/0'+(index+1)+'.php';
 $('div.ajaxContent').load(url, success);
}
function ajaxCategorie(){
    var index = $menu1.find('li a').index(this);
     $('div.ajaxContent').html('<p style="color:#4CC3EC; text-align:center; margin-top:45px;">Loading...<img src="img/loading.gif" /></p>');
    switch(index){
        case 0 :

              $('div.ajaxContent').stop().animate({marginTop: 0}, 1000,'linear', function(){ajaxCallTimeout(index)});
        break;
        case 1 : 

              $('div.ajaxContent').stop().animate({marginTop: 0}, 1000,'linear', function(){ajaxCallTimeout(index)});
        break;
        case 2 : 

              $('div.ajaxContent').stop().animate({marginTop: 0}, 1000,'linear',function(){ajaxCallTimeout(index)});
        break;
        case 3 : 

              $('div.ajaxContent').stop().animate({marginTop: 0}, 1000,'linear', function(){ajaxCallTimeout(index)});
        break;
        case 4 : 

              $('div.ajaxContent').stop().animate({marginTop:0}, 1000,'linear', function(){ajaxCallTimeout(index)});
        break;
        case 5 : 

              $('div.ajaxContent').stop().animate({marginTop: 0}, 1000,'linear', function(){ajaxCallTimeout(index)});
        break;
        case 6 : 

              $('div.ajaxContent').stop().animate({marginTop: 0}, 1000,'linear', function(){ajaxCallTimeout(index)});
        break;


    }
}

$menu1.find('li a').bind('click', ajaxCategorie);

});

Here is the script for the slider

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.min.js">\x3C/script>')</script>

<script defer src="jquery.flexslider.js"></script>

<script type="text/javascript">
 $(function(){
  SyntaxHighlighter.all();
});
$(window).load(function(){
  $('.flexslider').flexslider({
    animation: "slide"
  });
});

Can someone tell me what I am missing or point me out a tutorial ?

查看全部
weixin_33720956
weixin_33720956
2012/11/27 19:13
  • ajax
  • flexslider
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

1个回复