I've also tried many ways but none where really working... Then I did it manually, and it works now: Save the slider data before changed by flexslider, when window is resizing: destroy flexslider (https://stackoverflow.com/a/16334046/7334422) and delete node completely, manually add original slider node that was saved in data, add it again and initialize flexslider... because this is quite expensive I also added a resized method (https://stackoverflow.com/a/40534918/7334422), in order to not being executed while resizing... Yes it is some code and it's a bit hacky, but it's working :)
$.fn.resized = function (callback, timeout) {
$(this).resize(function () {
var $this = $(this);
if ($this.data('resizeTimeout')) {
clearTimeout($this.data('resizeTimeout'));
}
$this.data('resizeTimeout', setTimeout(callback, timeout));
});
};
function myFlexInit(slider){
slider.data("originalslider", slider.parent().html());
slider.flexslider({
animation: "slide",
//... your options here
});
}
$(".flexslider").each(function() {
myFlexInit($(this));
});
$(window).resized(function(){
$(".flexslider").each(function() {
$(this).removeData("flexslider");
parent = $(this).parent();
originalslider = $(this).data("originalslider");
$(this).remove();
parent.append(originalslider);
newslider = parent.children().first();
myFlexInit(newslider);
});
}, 200);
You better wrap your slider in an own unique container:
<div class="sliderparent">
<div class="flexslider">
<ul class="slides">
</ul>
</div>
</div>