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

"Uncaught ReferenceError: Cookielaw is not defined" with django-pipeline javascript wrapper enabled #30

Open
cydvd opened this issue Nov 18, 2016 · 2 comments

Comments

@cydvd
Copy link

cydvd commented Nov 18, 2016

Using django-pipeline for static compression, all javascript output is wrapped in an anonymous function, as security measure.

The click on button I agree fire Cookielaw.createCookielawCookie(); and generate the exception Uncaught ReferenceError: Cookielaw is not defined(…)

A chunk of the generated code:

(function(){var e={createCookie:function(e,t,n){var r=new Date,i="";n?(r.setTime(r.getTime()+n*24*60*60*1e3),i="; expires="+r.toGMTString()):i="",document.cookie=e+"="+t+i+"; path=/"},createCookielawCookie:function(){this.createCookie("cookielaw_accepted","1",3650),typeof window.jQuery=="function"?jQuery("#CookielawBanner").slideUp():document.getElementById("CookielawBanner").style.display="none"}}}).call(this);

With 'DISABLE_WRAPPER': Falseon pipeline configuration, all works as expected.

@cydvd cydvd changed the title "Uncaught ReferenceError: Cookielaw is not defined" when javascript is wrapped in an anonimous function "Uncaught ReferenceError: Cookielaw is not defined" with django-pipeline javascript wrapper enabled Nov 18, 2016
@piotrkilczuk
Copy link
Member

Thanks for reporting the issue.

I shall find time to look into this in the next two weeks (unless you could look into this yourself maybe?).

@JuanCarlos-Arce
Copy link

Hi,

I've found the same situation and I fixed it just adding the js file manually in the base.html

<script type="text/javascript" src="{% static 'cookielaw/js/cookielaw.js' %}"></script>

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

3 participants