Pregunta

Tengo este código:

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

Utilizo pestañas jQuery con un juego de cookies. Si no se establece una cookie, quiero ocultar las pestañas. Tengo el complemento jQuery.cookie instalado que era requerido.

Mi pregunta

¿Cómo puedo verificar si la cookie de pestañas está configurada o no?

¿Fue útil?

Solución

Debes usar el set y obtener

//getter
var cookie = $( ".selector" ).tabs( "option", "cookie" );
//setter
$( ".selector" ).tabs( "option", "cookie", { expires: 30 } );

EDITAR

Establezca el nombre de la cookie y use Getter y Setter

 $("#selector").tabs({
        cookie: {
            name: 'mycookie',
            expires: 10
        }
    });


        Get the Cookie 
        alert($.cookie('mycookie'));

        Set the Cookie 
        $.cookie('mycookie', null);

Otros consejos

¿No podrías hacerlo con el método Getter de 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 

Algo como

var cookieVal = $.cookie('ui-tabs-1');
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top