cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.4.1 Click events are inconsistent in website

Magento 2.4.1 Click events are inconsistent in website

Magento 2.4.1 Click events are inconsistent in website(Magento Cloud), sometimes it is working and sometimes not. After hard refresh, the issue fixes automatically for sometime. Can anyone please help with permanent fix..

1 REPLY 1

Re: Magento 2.4.1 Click events are inconsistent in website

Hello @madhanagope422

Greetings of the day!

 

You have to set jQuery dependency for your custom script. You have an occurrence of this problem due to a dependency issue. To add dependency check the following :

 

1. For Module/Extension Level
You can set at module/extension level dependency like below,
app/code/Packagename/Modulename/view/frontend/requirejs-config.js

var config = {
    paths: {            
            'slider': "Packagename_Modulename/js/slider"
        },   
    shim: {
        'slider': {
            deps: ['jquery']
        }
    }
};

2. Add slider.js inside path, app/code/Packagename/Modulename/view/frontend/web/js/slider.js
You can use any template file like this,

<script>
    require(["jquery","slider"],function($)(){
        $(document).ready(function() {
            $(element).slider({
                   //option
            });
        });
    });
</script>

3. Run php bin/magento c:f

 

I hope this will help you to solve your issue.

If not, feel free to contact us.

If yes, then click KUDOS and accept as a solution.

Thank you!