Why is my line of code not working , even though the function is firing inside bxslider.

Why is my line of code not working , even though the function is firing inside bxslider.

iam just using bxslider and came across a funny fug MY PAGE  . the BUG can be seen in discussion on that thread.

my jQuery initialization code is as follows:


  1. $(window).on('load' , function(){

  2. var bxslider = $('.projects .bx-slider').bxSlider({
  3.  mode: 'vertical',
  4.  minSlides: 3,
  5.  slideWidth:304,
  6.  slideMargin: 8,
  7.  onSlideAfter: function(elem , old , newi){
  8.   /*var idx = elem.index(),
  9.   src = $('.bx-slider li').eq(idx).find('img').attr('src');
  10.   console.log(elem.index());
  11.   $('.active-project-img img').attr('src' , src);*/
  12.  },
  13.  onSliderLoad: function(){
  14.   // alert('yel');
  15.   console.log('loaded');
  16.              $(".projects .bx-slider").css("visibility", "visible");
  17.          }
  18.   
  19. });


  20. $(window).on('resize' , function(){

  21. if($(window).width() < 992 ) {
  22. bxslider.reloadSlider({
  23.    mode: 'horizontal',
  24.    minSlides: 3,
  25.    maxSlides:4,
  26.    slideWidth:304,
  27.    slideMargin: 8,
  28.    onSlideAfter: function(elem , old , newi){
  29.     /*var idx = elem.index(),
  30.     src = $('.bx-slider li').eq(idx).find('img').attr('src');
  31.     console.log(elem.index());
  32.     $('.active-project-img img').attr('src' , src);*/
  33.    }
  34. });

  35. } else {
  36. bxslider.reloadSlider({
  37.    mode: 'vertical',
  38.    minSlides: 3,
  39.    slideWidth:304,
  40.    slideMargin: 8,
  41.    onSlideAfter: function(elem , old , newi){
  42.     /*var idx = elem.index(),
  43.     src = $('.bx-slider li').eq(idx).find('img').attr('src');
  44.     console.log(elem.index());
  45.     $('.active-project-img img').attr('src' , src);*/
  46.    }
  47. });

  48. }

  49. dynamicHeight();

  50. /* To give height to main image container */

  51. }).trigger('resize');

  52. });

The code pertaining to this BUG is here:

  1. var bxslider = $('.projects .bx-slider').bxSlider({
  2.  mode: 'vertical',
  3.  minSlides: 3,
  4.  slideWidth:304,
  5.  slideMargin: 8,
  6.  onSlideAfter: function(elem , old , newi){
  7.   /*var idx = elem.index(),
  8.   src = $('.bx-slider li').eq(idx).find('img').attr('src');
  9.   console.log(elem.index());
  10.   $('.active-project-img img').attr('src' , src);*/
  11.  },
  12.  onSliderLoad: function(){
  13.   // alert('yel');
  14.   console.log('loaded');
  15.              $(".projects .bx-slider").css("visibility", "visible");
  16.          }
  17.   
  18. });
ok , so now i have hidden.bx-slider in the css using visibility:hidden , and when the slider images are done loading , the onSliderLoad function is supposed to fire and IT DOES !! .. but this line , inside the function :

  1.              $(".projects .bx-slider").css("visibility", "visible");
has no effect what so ever , now if i go and post the line in the the console and hit enter IT WORKS !! . but why is that line of code not working issue the function and also how do i solve this issue of bxslider loading infinity ! ?