• Resolved kwebdesign

    (@kwebdesign)


    When I select an option from the Filter Product By Attribute dropdown, the page takes a while to load.

    I’ve therefore attempted to add a loading GIF.
    I thought it would be fairly simple with the On Change Event.
    It works fine, but not the first selection.

    You can view a demo here…

    If you select a Make, the page will refresh.
    If you select another Make afterwards, the Loading GIF will show.
    How can I trigger an event on the initial selection?

    https://woodemo.devrap.co.uk/product-category/wipers/

    I’ve tried various workarounds, but neither are working.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi @kwebdesign ??

    Could you please share a link to your site so that I can check?

    Thank you!

    Thread Starter kwebdesign

    (@kwebdesign)

    There is a link to my site in the original post.

    Thread Starter kwebdesign

    (@kwebdesign)

    I’ve also set up a blank install, with minimal plugins and the On Change Event fired on the first selection.

    https://bugs.devrap.co.uk/shop/

    I used a plugin (Simple Custom CSS and JS) to add the code in this instance.

    I’ve tried the same plugin in my website experiencing the issue and it works as expected.

    Any ideas why the code below works when inserted via the plugin, but when included in my JS file, it only fires on the 2nd time a selection is made.

    jQuery(document).ready(function( $ ){
      $('.woocommerce-widget-layered-nav-dropdown select').change(function() {
        alert('Changed');
      });
    });

    I’m using the following to include my JS…

    wp_register_script('main', get_template_directory_uri() . '/js/main.js', 'jquery', false, false);

    I did have true at the end but have just changed it to false to see if loading in the header helped.

    • This reply was modified 3 years, 4 months ago by kwebdesign. Reason: Code Highlight Incorrect
    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Apologies for the delay, @kwebdesign!

    At the moment, there’s no default option for that in WooCommerce, and setting that as the default would require quite a bit of additional coding. Please kindly note that this requires some custom coding – which goes beyond the scope of support we are able to provide in this forum.

    However, I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    If you do require more help with the actual coding, we’d recommend you hire a developer who can take a look at this, quote you for their services and help you add this feature to your site. We’d recommend getting in touch with a web developer or one of the customization experts listed at https://woocommerce.com/customizations/.

    Cheers.

    Thread Starter kwebdesign

    (@kwebdesign)

    Thanks for looking into this, but I’ll use the plugin to place the required JavaScript.

    Feel free to close.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Filter Product By Attribute Select On Change Event Not Firing On Initial Choice’ is closed to new replies.