Search code examples
jquerycolorboxjcarousel

rebuild jcarousel in colorbox


I have jcarousel, I create it by drupal module print it in hidden(diplay:none)element("main-content" it work correctly here), then I create colorbox with that

   $('.quicktabs-views-group  .frame-colorbox').colorbox({
        html: function() {
              return $(this).siblings('.main-content').html(); 
               },
        width:'950px',
        rel: 'group_0',
        opacity : 0.8, 
});

but jcarousel not work in colorbox,I know it because of geting html and put it in colorbox, what is solution,how can I have jcarousel in color box?

enter image description here


Solution

  • http://jsfiddle.net/v7g0vy2d/

    $('#test').colorbox({    
        html: $('.main-content').html(), // get carousel html
    
        onComplete:function(){   //Callback that fires right after 
                                 //loaded content is displayed.   
    
            initCarusel()        //Calls a function that creates
    
        }
    });
    
    function initCarusel()
    {
           $('.jcarousel').jcarousel();  
           ...                  // rest of the code
    }