Had this same issue. I used the markup below and initially hid the containing <div class="bxsliderWrapper">
with CSS display: none;
I noticed the width of the slides <div class="slide">
were rendered at 1px.
I suspect it has something to do with the responsive featured taking the dimensions of the initial container, which was hidden, and defining inline styles for each slide to match.
<div class="bxsliderWrapper">
<div class="bxslider">
<div class="slide">Your Content</div>
<div class="slide">Your Content</div>
<div class="slide">Your Content</div>
</div>
</div>
My solution is similar to what bradrice mentioned above about using the built in call-back functions. I just added the reloadSlider()
function to the show()
function instead.
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function(){
var homeSlider = $j('.bxslider').bxSlider();
$j(".bxsliderWrapper").show(0, "swing", function(){homeSlider.reloadSlider();});
});
</script>
It triggers the reload once show() is complete.
.
EDITED
The original solution above worked initially but I had issues when the cache was cleared during a hard refresh shift + REFRESH
. I'm assuming the elements targeted by the .show()
function were not available in time or the resources were not loaded yet. (I'm guessing) Below is a fix for this behavior.
Instead of hiding the Bx Slider containing <div>
with display: none;
, I hid the slide images using the visibility
CSS attribute.
.bxslider .slide {
visibility: hidden;
}
This allows the slider to render at the correct size without seeing the images on screen until they are ready. Then I used the jQuery .css()
method triggered by $j(window).load()
to change the visibility after the page has loaded. This ensured that all the code and elements existed before displaying them.
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function(){
var homeSlider = $j('.bxslider').bxSlider();
});
$j(window).load(function(){
$j(".bxslider .slide").css("visibility", "visible");
});
</script>
This method also worked with multiple sliders on the same page. I found the .show()
method caused all instances of the slider to break. I'm only guessing at why this is a better solution but maybe someone can add some info to understand this better.