Forums › Forums › Search & Filter Pro › AJAX initialization In Safari
- This topic has 10 replies, 2 voices, and was last updated 10 years, 4 months ago by Ross.
-
Anonymous(Private) July 8, 2014 at 6:26 pm #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(Private) July 9, 2014 at 1:20 pm #2287Hey 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(Private) July 16, 2014 at 4:24 pm #2568Any 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(Private) July 17, 2014 at 8:50 pm #2622Hey 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(Private) July 24, 2014 at 1:46 pm #2891Hey highfilter, I’m hopeful I can push a fix for this tonight ๐
Ross Moderator(Private) July 27, 2014 at 9:06 pm #2960Hey 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(Private) July 28, 2014 at 5:46 pm #2996Hey 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(Private) July 29, 2014 at 1:32 pm #3055Hey 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(Private) July 29, 2014 at 7:36 pm #3064In 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. ๐
-
AuthorPosts