Forums Forums Search & Filter Pro Ajax Hook – Complete

Viewing 10 posts - 1 through 10 (of 10 total)
  • Trevor
    #104437

    You will likely need to wrap it in a function for WordPress to use, like this:

    (function ( $ ) {
      "use strict";
      $(document).on("sf:ajaxfinish", ".searchandfilter", function(){
        console.log("ajax complete");
        //so load your lightbox or JS scripts here again
      });
    }(jQuery));
    Anonymous
    #104624

    Thanks for answering.

    I replaced the code, but it doesn’t work. You can find the website and JS file here:
    Website: bit.ly/2pfR6m7
    JavaScript: bit.ly/2puGkJR

    Trevor
    #104731

    OK, but what do you want it to do? This line:

    //so load your lightbox or JS scripts here again

    should have whatever code you need to run instead. The line as it is, is a comment only, so nothing will happen.

    Anonymous
    #104733

    I want to check if the code works. The line
    console.log("ajax complete");
    should give me something in the console, but it doesn’t. It looks like this hook doesn’t work.

    Trevor
    #104735

    Where on the page is the search form?

    You need a form on the page setup to use Ajax. When Ajax is used, it will trigger this code.

    Anonymous
    #104737

    I use the plugin for filtering on this page: bit.ly/2pfR6m7
    The form is on the left side.

    After changing one of the options i want to fire the JS function.

    Trevor
    #104743

    Where on that page? I do not see it? I have looked through the page source, and I do not see it.

    Anonymous
    #104745

    Sorry! There was an IP blocking active. Now it’s public.

    Trevor
    #104756

    Ah, now I see it. I will need to refer this to the developer, as I cannot see what the issue is.

    Ross Moderator
    #105129

    Hi Corné

    I just did a test locally and no issue.

    Had a look at your site and nothing sticks out.

    What I think *could* be happening is that some other Javascript in your theme or another plugin, could be removing the event handlers from document, which means our events do not get picked up at all.

    A couple of things to test:

    1) After "use strict"; add a console.log("test");, just to make sure the script is loading – this way you’ll see “test” in the console on page load – final code would look like:

    (function ( $ ) {
      "use strict";
      console.log("test")
      $(document).on("sf:ajaxfinish", ".searchandfilter", function(){
        console.log("ajax complete");
        //so load your lightbox or JS scripts here again
      });
    }(jQuery));

    2) Test S&F on a clean install, and test this code. I’ve just tested with 2015 and 2016 themes, and the events are fired just fine.

    Hope that helps.

    Thanks

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