Forums › Forums › Search & Filter Pro › js a script doesn't work after loading of the filter
- This topic has 5 replies, 2 voices, and was last updated 9 years, 1 month ago by Ross.
-
Anonymous(Private) November 2, 2014 at 5:50 pm #6841
Hello. Help to repair. If I use “filter category” (sidebar).
Example.
1. Open the page http://test.pandoragroup.ru/category-2/
2. Press the cart (post 2 product). Works.
3. Now choose “category 2” in the filter. Also repeat point 2. Doesn’t work.What shall I do?
Anonymous(Private) November 2, 2014 at 5:59 pm #6842I found this code
$(".searchandfilter").on("sf:ajaxstart",function(){ console.log("ajax start"); }); $(".searchandfilter").on("sf:ajaxfinish",function(){ console.log("ajax complete"); //so load your lightbox or JS scripts here again });
Explain please as to integrate this code into mine of the site.
Ross Moderator(Private) November 6, 2014 at 11:07 am #7102Hey Rozhnov, it looks like you managed to get it working 🙂
Anonymous(Private) September 23, 2015 at 9:49 am #25520Hi Ross. Why does not work the script?
<script type="text/javascript"> $(document).on("sf:ajaxstart", ".searchandfilter", function(){console.log("ajax start");}); $(document).on("sf:ajaxfinish", ".searchandfilter", function(){console.log("ajax complete"); document.write("<h1>hi all!</h1>");}); $(document).on("sf:init", ".searchandfilter", function(){console.log("S&F JS initialised");}); </script>
Page for example, http://www.mega-pools.ru/?sfid=41738&_sft_category=category-1
Ross Moderator(Private) September 23, 2015 at 10:08 am #25522Hey there – sorry for the absence on email – as you probably guessed I have been super busy with this release.
I’ve tested the above code various times now in different setups and all seemed to be working ok.
The only thing I notice on the above that you may be doing wrong is you are not wrapping your jQuery in ready events or a function.
Try changing above to:
<script type="text/javascript"> (function ( $ ) { "use strict"; $(function () { $(document).on("sf:ajaxstart", ".searchandfilter", function(){console.log("ajax start");}); $(document).on("sf:ajaxfinish", ".searchandfilter", function(){console.log("ajax complete"); document.write("<h1>hi all!</h1>");}); $(document).on("sf:init", ".searchandfilter", function(){console.log("S&F JS initialised");}); }); }(jQuery)); </script>
Let me know
Thanks
-
AuthorPosts