Forums › Forums › Search & Filter Pro › AJAX loading killing Slick JS slider
Tagged: ajax, slick-slider
- This topic has 18 replies, 2 voices, and was last updated 7 years, 3 months ago by
Trevor.
-
Trevor(Private) April 3, 2018 at 5:12 pm #169698
Your code might need to look like this:
<script>(function ( $ ) { "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); $('.slick-slider').slick({ autoplay: false, fade: false, speed: 1000, autoplaySpeed: 6000, prevArrow: '<p class="one-half first left-arrow">←</p>', nextArrow: '<p class="one-half right-arrow">→</p>' }); }); }(jQuery));</script>
I think.
Anonymous(Private) April 3, 2018 at 5:22 pm #169700Hi Trevor
This doesn’t work unfortunately. I know this is an external script so it’s not your job to fix it!
Just to check there’s not anything else I’m missing, where is this script supposed to go? In my scripts.js or in my custom search ‘results.php’?
Trevor(Private) April 4, 2018 at 8:20 am #169858It is a question of figuring out how to re-initialise the slick script. Stackexchange may be the best source of help/snippets. For example, see this:
https://stackoverflow.com/questions/27795730/reinitialize-slick-js-after-successful-ajax-call
Anonymous(Private) April 4, 2018 at 9:37 am #169903Hi Trevor
I looked at this yesterday and thought this would be my fix. I understand the process with re-initialising Slick, my problem with this code is how the ajax call code fits in to your code that you supply on the FAQ page e.g.
this:
$.ajax({ type: 'get', url: '/public/index', dataType: 'script', data: data_send, success: function() { slickCarousel(); } });
and this:
//detects when the ajax request has finished and the content has been updated // - add scripts that apply to your results here $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); //so load your lightbox or JS scripts here again });
Trevor(Private) April 4, 2018 at 9:53 am #169909I showed in my earlier post (#169698) how it can be integrated. I myself have used this structure of code many times, so I know it works in theory (but I have not done it with slick). Whatever code you need to be run after ajax is triggered, needs to be in the place where I used it.
Anonymous(Private) April 4, 2018 at 10:21 am #169924Hi Trevor.
I more meant in the context of the ajax function which wasn’t explained. However I can’t even seem to get any evidence of the ajax refresh triggering. I have put a breakpoint in the code and it doesn’t get triggered when the dropdown is used and ajax is used to refresh the results.
I have done a test with the below alert and I can’t get this to work either. This is all on my local server, let me know if you want me to put this live for you to have a look at.
(function ( $ ) { "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); window.alert("sometext"); }); }(jQuery));
Anonymous(Private) April 4, 2018 at 10:40 am #169935I just pushed this live so you can see on the same link that I sent before. You might need to do a hard refresh to see the changes.
The
ajax complete
should fire as Aldgate is selected in the dropdown as reloads as far as I know, but I can’t see anything to that end -
AuthorPosts