Search code examples
javascriptzurb-foundationzurb-joyride

Joyride - while cookie_monster: true nothing works


Working with Foundation is really easy but I cannot figure out what to do in this case. I have dig a lot through Google I tested about 6 different approaches how to launch joyride only once, at first visit on my page. Outcome of this approaches were always different, multiplied slider (god knows why), blank page or just nothing changed.

If I understand well I should set in this part of 'foundation.joyride.js' monster_cookie: true, BUT after that joyride don't launch even once, if cookie_monster: false, I can see joyride at every load of main/sub pages. I tried cleaning memory and other simple stuff, but nothing works. Do you have any working/tested solution?

I have 5.0.0 version of joyride, when I pasted the code for ver: 5.2.1 joyride stopped working.

I am using Foundation as Wordpress theme so here's part of my functions.php:

if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);

function my_jquery_enqueue() {

    //Load jQuery 2.0

    wp_deregister_script('jquery');
    wp_register_script('jquery', "http".($_SERVER['SERVER_PORT'] == 443 ? "s" : "")."://code.jquery.com/jquery-2.1.0.min.js", false, null);
    wp_enqueue_script('jquery');

    //Load Foundation.js
    wp_enqueue_script('foundation_js', get_template_directory_uri().'/js/foundation.js', array('jquery'), false, true);
    //Load faq-crm.js
    wp_enqueue_script('faq-crm_js', get_template_directory_uri().'/js/faq-crm.js', array('jquery', 'foundation_js'), false, true);
    //modernizr.js
    wp_enqueue_script('modernizr_js', get_template_directory_uri().'/js/vendor/modernizr.js', array('jquery', 'foundation_js', 'faq-crm_js'), false, true);
    // Load slider orbit.js
    wp_enqueue_script('orbit_slider_js', get_template_directory_uri().'/js/foundation/foundation.orbit.js', array('jquery', 'foundation_js', 'faq-crm_js'), false, true);
    // Load magellan.js 
    wp_enqueue_script('magellan_js', get_template_directory_uri().'/js/foundation/foundation.magellan.js', array('jquery', 'foundation_js', 'faq-crm_js'), false, true);
    //Load topbar.js
    wp_enqueue_script('topbar_js', get_template_directory_uri().'/js/foundation/foundation.topbar.js', array('jquery', 'foundation_js', 'faq-crm_js'), false, true);
    //Load modal.js
    wp_enqueue_script('modal_js', get_template_directory_uri().'/js/foundation/foundation.reveal.js', array('jquery', 'foundation_js', 'faq-crm_js'), false, true);
    //Load joyride.js
    wp_enqueue_script('joyride_js', get_template_directory_uri().'/js/foundation/foundation.joyride.js', array('jquery', 'foundation_js', 'faq-crm_js'), false, true);
    //Load cookie.js
    wp_enqueue_script('cookie_js', get_template_directory_uri().'/js/vendor/jquery.cookie.js', array('jquery', 'foundation_js', 'faq-crm_js'), false, true);
}

Solution

  • I'm not sure you're using the correct options. I've used Zurb's Joyride on a project and just configured the cookie setting inside the options of the joyride function call like this:

    <script>
    $(window).load(function() {
        $('#contentID').joyride({
            'cookieMonster': true,    // true/false for whether cookies are used
            'cookieName': 'JoyRide',  // choose your own cookie name
        });
      });
    });
    </script>
    

    The basics of setting this up and the options available are here: http://zurb.com/playground/jquery-joyride-feature-tour-plugin