Forums › Forums › Search & Filter Pro › Sort not working after first results
- This topic has 35 replies, 2 voices, and was last updated 8 years, 10 months ago by Ross.
-
Anonymous(Private) December 15, 2015 at 7:34 pm #32258
Thanks! That definitely helped and was easy!
One more thing…the video resources show an embedded video that utilizes the default [video] shortcode from WordPress. Whenever those resources are viewed in the search, they don’t load properly. The generated code leads me to believe that it is partially working but a script or some component isn’t loading along the way to allow it to display properly.
Any chance you could look at this? Thanks! Based on the test script that I used before based on the link that you sent, I don’t know how to troubleshoot this issue. (the provided javascript was not working)
Thanks!
Ross Moderator(Private) December 16, 2015 at 11:23 am #32296Hi Stephanie
The reason you are having layout / masonry issues is because you are using ajax.
If you disable ajax, I’m assuming the rest works well?
When using JS to control layouts with Ajax, the issue is that all the scripts that would normally get triggered on a regular page load don’t occur when an ajax request is performed.
If you take a look at this JS event (first question):
http://www.designsandcode.com/wordpress-plugins/search-filter-pro/faqs/You’ll notice there is an event for detecting when ajax content has loaded.
You must use this event to reload any scripts like your masonry script.
Thanks
Anonymous(Private) December 16, 2015 at 10:42 pm #32394$(document).on(“sf:ajaxfinish”, “.searchandfilter”, function(){
console.log(“ajax complete”);
//so load your lightbox or JS scripts here again
});does not write to the console.
This is where you want to load scripts, correct?
Of the 3, only:
$(document).on(“sf:init”, “.searchandfilter”, function(){
console.log(“S&F JS initialised”);
});
writes to the console…I’m not sure where to go from here…
-StephRoss Moderator(Private) December 17, 2015 at 10:19 pm #32454Hey Steph
That odd – I’m looking into the events now and will patch the plugin if there is a bug here.
Thanks
Ross Moderator(Private) December 31, 2015 at 12:15 am #33071Hi Steph
I double checked this and no errors my side.
This is the code copied from my JS file:
$(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); //so load your lightbox or JS scripts here again }); $(document).on("sf:ajaxstart", ".searchandfilter", function(){ console.log("ajax start"); });
Depending on where you put this code though it might not work.
Make sure that it is being places properly inside a jQuery ready function or something similar like:
( function( $ ) { $( document ).ready( function() { $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); //so load your lightbox or JS scripts here again }); $(document).on("sf:ajaxstart", ".searchandfilter", function(){ console.log("ajax start"); }); } ); } )( jQuery );
Let me know how you get on.
PS just had another idea, why don’t you test with the 2015 theme? Maybe your theme is not doing something in the regular way, or the code might be added at the wrong point.
If you try the 2015 theme, pasting the above code at the very end of
twentyfifteen/js/functions.js
seems to work fine and the events are always fired.Thanks
Anonymous(Private) December 31, 2015 at 9:03 pm #33113I cannot mimic this in the 2015 theme. The resources post type and the ajax functionality is part of the theme that I’m using. It’s not an equal comparison.
Obviously there is something in the way of this working and I need to figure it out on THIS site.I have this exact code written into the end of the template file (near the footer of the document…I tried moving it into the head too, to no avail):
jQuery(document).ready(function($) { console.log('this is 1'); $(document).on("sf:init", ".searchandfilter", function(){ console.log("ajax init"); //so load your lightbox or JS scripts here again }); $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); //so load your lightbox or JS scripts here again }); console.log('this is 2'); $(document).on("sf:ajaxstart", ".searchandfilter", function(){ console.log("ajax start"); }); console.log('this is 3'); });
I get:
this is 1
this is 2
this is 3
ajax init…in the console. I am not having script error or none of it would work. And the sf:init event works but not the ajax ones.
Could you please look at the particular website and see if you can see what the problem might be?
http://befirst.wpengine.com/resources/
user: demo
pw: ecbef15http://betest.wpengine.com/ is also a fresh copy of the site as a few minutes ago and still has your user if you want to go poke around…
user: demo
pw: ecbef15Thanks.
Ross Moderator(Private) January 5, 2016 at 11:28 am #33344Hi Stephanie
The point of testing in 2015 is to identify if there is an issue in your theme.
Perhaps you can create a test search form, that searches only posts, and uses regular categories and tags.
Test this on your current theme.
Then test this on 2015 – and add the code in I provided to the file mentioned above.
As I mentioned already, I’ve done some tests here, and the events are firing fine on all themes I’ve tested.
So if the above works in 2015 for you, then either, you are not placing the JS code in the correct place for your theme (perhaps you can ask them where to do so) or there is a conflict in the way the theme uses its JS – perhaps there is some JS that removes events from Search & Filter – preventing you from receiving those events.
Anyway, its important to test in 2015 to make this clarification.
If its still not working in 2015, then I would suggest a plugin is causing you issues – so then try to disable your other plugins and re-enable 1 by 1 to identify where the issue is coming from.
Thanks
-
AuthorPosts