I am trying to reinitialize FlexSlider with a page refresh when a new gallery list is called asynchronous.
I would have thought that the subroutine below would work, but it is not. It appears that the first FlexSlider is saved, although new images have been successfully uploaded.
Is there a way to destroy and 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();
source share