Forums Forums Search & Filter Pro Problem with ajax results missing audio player

Tagged: 

Viewing 10 posts - 1 through 10 (of 11 total)
  • Ross Moderator
    #14444

    Hi Adrian

    What is happening is, when the page loads, your theme is doing all kinds of stuff like loading the scripts for your audio player and attaching them to the page.

    Then, once you use ajax, these audio player are removed, and new results are brought in. However this scenario is different because your theme doesn’t run the scripts it needs to setup those audio players.

    Take a look at the first question here:
    http://www.designsandcode.com/wordpress-plugins/search-filter-pro/faqs/

    Basically you need to run the same scripts (for setting up audio players) that your theme runs when ajax has finished loading – your theme developer may know of some functions that could do this.

    Thanks

    Anonymous
    #14457

    Hi Ross,

    Thanks for the quick reply. The FAQ helped a lot, and I just added the following into my .js file and it works great:

    $(“.searchandfilter”).on(“sf:ajaxfinish”,function(){
    $(‘video,audio’).mediaelementplayer();
    });

    Users should not need to refresh the page, but if they do, the title of the page still changes to “Blog | Site Title”

    Any further suggestions?

    Anonymous
    #14464

    Thanks Ross – spot on. You are a patient man.

    Here is the code I used in functions.php:

    add_filter('wpseo_title','search_meta_title');
    function search_meta_title($data){
    	global $sf_form_data;
    	if($sf_form_data->form_id()==1272)
    	{
    	return 'Sermons';
    	}
    	else
    	{
    	return $data;
    	}
    }
    Ross Moderator
    #14475

    No problem 🙂

    Anonymous
    #127088

    Hello, I have the same problem with my audio player that changes shape and color once the rescheerche display. I see you say you have to put in the js:
    $ ( “Searchandfilter.”) One (“sf: ajaxfinish.”, Function () {
    $ (‘Video, audio’) mediaelementplayer ().
    });
    But where exactly? This is serach-filter-build.js?
    cordially

    Anonymous
    #127103

    I put it in a separate .js file that is registered using wp_register_script and queued using wp_enqueue_script within functions.php in the usual way.

    Note your code is wrong in a number of ways. It should be:

    $(".searchandfilter").on("sf:ajaxfinish",function(){
      $('video,audio').mediaelementplayer();
    });
    Anonymous
    #127108

    Hello, thank you for your answer. But since I am a beginner, I did not understand the manipulation … Thank you for your patience.

    Trevor
    #127111

    If you are placing that code inline on the page, it would become like this:

    <script>(function ( $ ) {
      "use strict";
      $(document).on("sf:ajaxfinish", ".searchandfilter", function(){
        console.log("ajax complete");
        $('video,audio').mediaelementplayer();
      });
    }(jQuery));</script>
    Anonymous
    #127113

    It seems very daunting to start with, but there are plenty of tutorials on how to correctly enqueue script files (.js) E.g. https://premium.wpmudev.org/blog/adding-scripts-and-styles-wordpress-enqueueing/

    Add your code into a new .js file (E.g. website-scripts.js in the example) that is in your theme folder.

Viewing 10 posts - 1 through 10 (of 11 total)