Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery tabs with cookie - If cookie exists?

I have this code:

jQuery(document).ready(function($) {
        $( "#tabs" ).tabs({
            collapsible: true,
            fx: { height: 'toggle', duration: 'fast'},
            cookie: { expires: 30 }
        });
    });

I use jQuery tabs with a cookie set. If no cookie is set I want to hide the tabs. I have the jquery.cookie plugin installed that was required.

My question

How can I check if the tabs cookie is set or not?

like image 961
Jens Törnell Avatar asked Oct 18 '11 08:10

Jens Törnell


1 Answers

Couldn't you do it with the getter method from cookie.js:

* Get the value of a cookie with the given key.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String key The key of the cookie.
* @return The value of the cookie.
* @type String 

Something like

var cookieVal = $.cookie('ui-tabs-1');
like image 185
Marco Johannesen Avatar answered Sep 22 '22 21:09

Marco Johannesen