Forums › Forums › Search & Filter Pro › Ajax messing up Slick js script
Tagged: ajax, jquery conflict
- This topic has 19 replies, 2 voices, and was last updated 5 years, 8 months ago by Trevor.
-
Anonymous(Private) February 26, 2019 at 11:24 am #203284
I have this code in a separate js file where I initalize all jquery plugins :
jQuery(document).ready(function($){ $(".visuels-realisations").slick({ dots: false, infinite: true, autoplay: false, autoplaySpeed: 10000, slidesToShow: 2, slidesToScroll: 1 }); });
Trevor(Private) February 26, 2019 at 11:32 am #203286Ah, OK, try this then:
<script>(function ( $ ) { "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ $('.visuels-realisations').slick('unslick'); $(".visuels-realisations").slick({ dots: false, infinite: true, autoplay: false, autoplaySpeed: 10000, slidesToShow: 2, slidesToScroll: 1 }); }); }(jQuery));</script>
Anonymous(Private) February 26, 2019 at 12:02 pm #203288Like that in the plugin or in the js file ? If in the js file should I change it to :
jQuery(document).ready(function($){ "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ $('.visuels-realisations').slick('unslick'); $(".visuels-realisations").slick({ dots: false, infinite: true, autoplay: false, autoplaySpeed: 10000, slidesToShow: 2, slidesToScroll: 1 }); }); });
Or leave it as is ?
Because I tried on local to paste both your code and the one I pasted above un the js file and the sliders weren’t working anymore.
Trevor(Private) February 26, 2019 at 12:12 pm #203292Your js file might look like this now:
jQuery(document).ready(function($){ $(".visuels-realisations").slick({ dots: false, infinite: true, autoplay: false, autoplaySpeed: 10000, slidesToShow: 2, slidesToScroll: 1 }); }); (function ( $ ) { $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ $('.visuels-realisations').slick('unslick'); $(".visuels-realisations").slick({ dots: false, infinite: true, autoplay: false, autoplaySpeed: 10000, slidesToShow: 2, slidesToScroll: 1 }); }); }(jQuery));
Anonymous(Private) February 26, 2019 at 3:30 pm #203325He’s a screen of the errors : https://i.ibb.co/mctpjVB/Capture-d-e-cran-2019-02-26-a-16-28-31.png
And of the result : https://i.ibb.co/yVVQmfd/Capture-d-e-cran-2019-02-26-a-16-28-43.png
It displays the images as if the slider js was not installed. -
AuthorPosts