[Cookies Policy] Cookie Policy javascript error

[Cookies Policy] Cookie Policy javascript error

  
Forge Component
(4)
Published on 17 Jul by Carlos Alfaro
4 votes
Published on 17 Jul by Carlos Alfaro

I'm not good at javascript and I'm trying the Cookie Policy solution from the Forge, but when I try to use it, I'm getting an error in the following:


osjs(document).ready(
    function(){
        if(osjs('.warning_EU_cookiemsg').length >= 1){
            osjs('.CloseArea').click(
                function(){
                    osjs.cookie("AcceptCookies", 1, { expires : 365 });
                    osjs('.warning_EU_cookiemsg').slideUp();
                }
            );
       
            osjs('.warning_EU_cookiemsg').slideDown(500);
        }
    }
);


The error is osjs.cookie is not a function.  Am I missing something simple?  I would assume when you click on the close area, it should drop a cookie, but I don't see a function anywhere in the webblock that does that.

Any help is appreciated.

Cory

The jQuery UI library at some point stopped including the cookie() function, which was then made available through a plugin (this Cookie Policy plugin is almost 5 years old!).

To remove that error, you can include the jquery.cookie.js file contents in the JavaScript property of the "CookiesMessage" web block, before the script you copied in your post.

In the example provided as an attachment (a revised CookiePolicy OML file), I copied the contents of the following jquery.cookie.js file, minified it and included it in the JavaScript property of the web block:

https://github.com/jquery/jquery-ui/blob/c2a113b909a961f62371d9cd5763943628fc9707/external/jquery.cookie.js

Regards,
Pedro