whitecube / laravel-cookie-consent

Register, configure and ask for cookies consent in a EU-compliant way
MIT License
332 stars 41 forks source link

I get "window.LaravelCookieConsent is undefined" in console.log when i click on any button and it doesn't work #63

Open nourishingafrica opened 1 month ago

nourishingafrica commented 1 month ago

I get "window.LaravelCookieConsent is undefined" in console.log when i click on any button and it doesn't work

nourishingafrica commented 1 month ago
function handleAcceptEssentials(e) {
        e.preventDefault();
        if (window.LaravelCookieConsent && typeof window.LaravelCookieConsent.acceptEssentials === 'function') {
            window.LaravelCookieConsent.acceptEssentials();
            hideCookiePolicy();
        } else {
            console.error('LaravelCookieConsent.acceptEssentials is not available');
        }
    }``
toonvandenbos commented 1 month ago

Looks like the JS isn't included. Did you load the scripts into the page and check you don't have custom rules preventing them to run correctly?

nourishingafrica commented 1 month ago

I used the blade directives just as was stated in the guide. Although I have a vue.js app.js script on the page. I don't know if that's causing the conflict

toonvandenbos commented 1 month ago

Could be, can you see the JS file in the browser's network tab ?

captainscorch commented 1 week ago

I had a similar issue and found a solution, maybe this helps you: #64

Try to update the url prefix in cookieconsent.php to 'prefix' => 'cookieconsent',