Forums › Forums › Search & Filter Pro › problem with shortcode and ajax reload
- This topic has 7 replies, 2 voices, and was last updated 4 years, 5 months ago by Trevor.
-
Anonymous(Private) June 10, 2020 at 6:36 pm #248388
Hello,
I have a custom results.php. In this I load a shortcode:
if (!empty(get_field('_smt-gallery-shortcode'))) { $galleryShortcode = "[foogallery id=" . get_field('_smt-gallery-shortcode') . " paging_size=3]"; echo $galleryShortcode; echo do_shortcode("$galleryShortcode"); }
When th page is loaded the first time everything works fine. When I change the filter and the page is reloaded (ajax on) the shortcode is not shown.
When I diasble Ajax in the Search&Filter settings the whole page is reloaded and the shortcode is shown.
What can I do to load the shortcode together with ajax refresh.
Robert
Trevor(Private) June 10, 2020 at 7:15 pm #248393What plugin does the shortcode come from? If it is using JavaScript to expand the shortcode, that would be why this is happening. Can you show me the full file?
Please note that it is late here in the UK (gone 5PM) and we are closed now for the day, so I will likely not reply until tomorrow.
Trevor(Private) June 11, 2020 at 6:29 pm #248518It certainly looks as though that is the issue. Are you able to contact the author and ask how the shortcode can be refreshed on an Ajax load of the content? We have a jQuery/JavaScript that any code can be embedded in (you can show them this, it will make sense to them:
<script>(function ( $ ) { "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ // call your script or function here }); }(jQuery));</script>
But …, looking at the code, this might do it:
<script>(function ( $ ) { "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ $('.foogallery').foogallery(); }); }(jQuery));</script>
Assuming I have understood the problem, that the gallery isn’t working, yes?
-
AuthorPosts