I am trying to reinitialize FlexSlider with out page refresh when a new gallery listing is called asynchronously.
I would think the routine below would work but it doesn't. It seems like the first FlexSlider persists even though the new images are successfully loaded.
Is there a way to destroy, then rebuild the gallery?
Thanks
function flexInit() {
$('.flexslider').flexslider({
animation: "slide",
controlsContainer: ".paginator",
manualControls: 'a',
after: function(slider){
if(slider.atEnd == true) {
// ??? slider.destroy;
galBuild();
}
}
});
}
function galBuild() {
$.getJSON("/gallery/next/"+galID, function (data) {
var results = data.objects;
var list = $(".flexslider ul.slides");
var i = 0;
$.each(results, function () {
list.append('<li><p>' + results[i].title + '</p><img src="' + results[i].src + '"><p class="flex-caption">' + results[i++].caption + '</p></li>');
});
flexInit();
});
}
galBuild();