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 TypeError: jQuery(...).slideUp is not a function #58

Closed
feliche93 opened this issue Mar 25, 2020 · 2 comments
Closed

Uncaught TypeError: jQuery(...).slideUp is not a function #58

feliche93 opened this issue Mar 25, 2020 · 2 comments

Comments

@feliche93
Copy link

Hi thanks for this awesome package.

I followed all the steps but then when I click on agree, the banner does not slide up as expected. I get the following error message in the console:

Uncaught TypeError: jQuery(...).slideUp is not a function
    at Object.createCookielawCookie (cookielaw.js:19)
    at <anonymous>:1:11

Here are my files and how I linked the js file:

The js file is the same as in the repository:

var Cookielaw = {

    createCookie: function (name, value, days) {
        var date = new Date(),
            expires = '';
        if (days) {
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            expires = "; expires=" + date.toGMTString();
        } else {
            expires = "";
        }
        document.cookie = name + "=" + value + expires + "; path=/";
    },

    createCookielawCookie: function () {
        this.createCookie('cookielaw_accepted', '1', 10 * 365);

        if (typeof (window.jQuery) === 'function') {
            jQuery('#CookielawBanner').slideUp();
        } else {
            document.getElementById('CookielawBanner').style.display = 'none';
        }
    }

};

And these are my scripts in the base.html:

    <!-- Optional JavaScript -->
    <script type="text/javascript" src="static/cookielaw/js/cookielaw.js"></script>
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
        integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
        integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
        crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
        integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
        crossorigin="anonymous"></script>
    <script src="https://use.fontawesome.com/b8d759fc4a.js"></script>

Thanks for your help!

@grondman
Copy link

You're using a slimmed down version of jQuery (jquery-3.2.1.slim.min.js) which does indeed not include the slideUp function. Have a look at jQuery CDN for a correct <script> tag to use for the full version and you should be all set.

I think this issue can therefore be closed, but perhaps a piece of documentation can be added to inform users about this, as a lot of Bootstrap/Django tutorials indeed have users install the slim version.

@piotrkilczuk
Copy link
Member

v 2.2.0 removes any need for jQuery.

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