简体   繁体   中英

Could 'jekyll' interfere with jquery.cookie?

I have managed to implement jquery.cookie in another project with fancyapp with no problems; eg tested modal fires once, and to make it fire again I just delete the cookie and it will propagate again (see below).

UPDATE

Here is the example where it works; If you go to this page: http://avonexampleone.antonio-p-ortiz.com/prior.html click the banner, the modal will fire in the subsequent page and honor the expiration iejcookie('visited', 'yes', {expires: 1}); wont fire again till a day, And if you clear your cookies and test again the modal will fire. All as expected.

However, I have the same code in another project (jekyll blog), and it appears to work once in a while when tested.

Could there be some weird privacy concern or some setting in jekyll which would prevent this?

Any help would be appreciated!

HTML:

<a id="clickbanner" href="/assets/images/beauty_for_a_purpose/Beauty_for_a_Purpose_Sheri_Card_EN.jpg" rel="gallery"></

JS:

var j = jQuery.noConflict();

j(document).ready(function() {
    function openFancybox() {
        setTimeout(function() {
            j("#clickbanner").trigger('click');
        }, 500);

    };

    var visited = j.cookie('visited');
        if (visited == 'yes') {
            return false;
        } else {
            openFancybox();
        };
        j.cookie('visited', 'yes', {
            expires: 1
        });

    j("#clickbanner").click(function() {
        j.fancybox({
            href: this.href,
            type: "image",
            maxWidth: 750,
            maxHeight: 502
        });
        return false;
    });
});

It turns out the problem derived from the script tag path not being properly configured. As you can see in the image below, the pages are nested in folders and would need to be marked accordingly to get to the scripts.

So <script type="text/javascript" src="../../../assets/javascript/ya_jquery.fancybox.ready.function.js"></script> as an example did the trick!

Strange thing was, I wasn't getting an error in the console saying I was missing the scripts.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM