Forums Forums Search & Filter Pro AJAX initialization In Safari

Viewing 10 posts - 1 through 10 (of 11 total)
  • Anonymous
    #2276

    I have a Search & Filter Pro search form using AJAX, and use custom JS to style some of the dropdowns on page load. I also have checks to re-enable the scripts on sf:ajaxstart and sf:ajaxfinish events, which works – but the issue seems to be when you first visit the page using Safari as a browser, the search form instantly reloads and my custom JS doesn’t get fired again.

    Is there an initialization event I can run my custom JS on as well as the on start and finish? It only seems to be an issue when viewing the page in Safari, all other browsers just load the custom JS and it works. The on start and finish events work properly in Safari, but only after interacting with the form, not when the page initially loads up.

    Ross Moderator
    #2287

    Hey Highfilter, I’ll test this as soon as I can and see if I can provide a temporary workaround while I look at the issue.

    Thanks

    Anonymous
    #2316

    Perfect, really appreciate it. ๐Ÿ™‚

    Anonymous
    #2568

    Any updates on this?

    Test case would be:

    – Create a page called Custom Search, url: /custom-search
    – Embed shortcode from Search & Filter into the ‘page-custom-search.php’
    – In Search & Filter settings, check ‘Use a custom template for results?”. Set the filename to ‘page-custom-search.php’ and set the “Set a slug?” field to ‘custom-search’.
    – Make sure AJAX is on in Search & Filter.

    When you view the Custom Search page in Safari, you’ll get a refresh on the form for no reason. Even if there’s a pager in the results and you switch pages, it will refresh the page again after it loads.

    Ross Moderator
    #2622

    Hey highfilter

    I managed to have a look at the weekend and found the issue you were talking about but haven’t managed to patch a fix for it just yet :/

    I’ll let you know when I do – to be honest I can’t even supply a workaround as I haven’t managed to get it working yet…

    Will keep you updated, apologies for the wait..

    Ross Moderator
    #2891

    Hey highfilter, I’m hopeful I can push a fix for this tonight ๐Ÿ™‚

    Ross Moderator
    #2960

    Hey highfilter, I’ve added an initialisation hook which hopefully will help you – this will be released in the latest update (in a few hours time).

    This is how you use it:

    	$(".searchandfilter").on("sf:init",function(){
    		console.log("search form init!");
    	});

    Let me know, once I’ve released it if this works for you ๐Ÿ™‚

    Anonymous
    #2996

    Hey there,

    it doesn’t seem to be working. If I set a log message to show up on init, I can see it, but it seems to be too late or too early. If you have a pager for example, and change pages, the init will run but the form seems to just reload. For example, try adding a class to a <li> within the .searchandfilter, like so:

    
    $(".searchandfilter").on("sf:init",function(){
      console.log("search form init!");
      if($('.searchandfilter ul li.search-custom-class').length == 0) {
        $(".searchandfilter ul li").addClass("search-custom-class");
      }
    });
    

    If you switch pages or something that triggers the AJAX again, the class won’t be applied but you’ll see the console log fire.

    Thanks for your help.

    Ross Moderator
    #3055

    Hey highfilter

    The only thing I can think of is that your search form is inside your Ajax content selector? Make sure your form is not inside this content area and I’m hoping it will work for you?

    Alternatively, do you have the beta feature enabled in the settings box? Please make sure this is disabled :/

    Thanks

    Anonymous
    #3064

    In a page template, I have the shortcode in a div, outside the #content div. Content selector is “#content”.

    Setup is like:

    
    <div id="search-filter-cont">
      <?php echo do_shortcode('[searchandfilter id="438"]'); ?>
    </div>
    
    <div id="content">
      ...
    </div>
    

    I do not have the beta featured enabled either. Funny how it only doesn’t work properly in Safari. ๐Ÿ™

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