Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nourishingafrica opened this issue Sep 20, 2024 · 6 comments

Comments

@nourishingafrica
Copy link

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

@nourishingafrica
Copy link
Author

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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

@captainscorch
Copy link

captainscorch commented Oct 12, 2024

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',

@geertjanknapen1
Copy link

geertjanknapen1 commented Dec 5, 2024

I'm bumping this.
@captainscorch 's workaround does not work either.
On click of the 'Accept all' button I get the following error

Uncaught TypeError: Cannot read properties of undefined (reading 'acceptAll')

Which originates from the @cookieconsentscripts Blade directive, because window.LaravelCookieConsent is undefined.

I used the Installation guide with a Laravel 11.x installation.

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants