Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/04/2010, 17:29
mateando
 
Fecha de Ingreso: mayo-2009
Mensajes: 20
Antigüedad: 14 años, 11 meses
Puntos: 0
Pregunta Agregar COOKIE a un MENU

Hola a todos! vuelvo en busca de un poco de ayuda...

Resulta que tengo un menú vertical que se despliega con algo de jQuery, montado con esta estructura:
Código HTML:
Ver original
  1. <UL>
  2. <LI>TITULO SUPERIOR {+}
  3.  
  4. <ul>
  5. <li>Titulo 1</li>
  6. <li>Titulo 1</li>
  7. <li>Titulo 1</li>
  8. <li>Titulo 1</li>
  9. <li>Titulo 1</li>
  10. </ul>
  11.  
  12. </LI>
  13. </UL>

Y con el siguiente js:
Código Javascript:
Ver original
  1. <script type="text/javascript" >
  2.  
  3. // this tells jquery to run the function below once the DOM is ready
  4. $(document).ready(function() {
  5.  
  6. // choose text for the show/hide link - can contain HTML (e.g. an image)
  7. var showText='<img src="images/mas.png" width="16" height="16" alt="+" />';
  8. var hideText='<img src="images/menos.png" width="16" height="16" alt="-" />';
  9.  
  10. // initialise the visibility check
  11. var is_visible = false;
  12.  
  13. // append show/hide links to the element directly preceding the element with a class of "toggle"
  14. $('.toggle').prev().append('<a href="#" class="toggleLink">'+showText+'</a>');
  15.  
  16. // hide all of the elements with a class of 'toggle'
  17. $('.toggle').hide();
  18. // capture clicks on the toggle links
  19. $('a.toggleLink').click(function() {
  20.  
  21. // switch visibility
  22. is_visible = !is_visible;
  23.  
  24. // change the link depending on whether the element is shown or hidden
  25. $(this).html( (!is_visible) ? showText : hideText);
  26.  
  27. // toggle the display - uncomment the next line for a basic "accordion" style
  28. //$('.toggle').hide();$('a.toggleLink').html(showText);
  29. $(this).parent().next('.toggle').slideToggle('slow');
  30. return false;
  31. });
  32. });
  33. </script>

La pregunta del millon es: ¿ Como puedo insertarle un Cookie, para mantener el menu abierto/cerrado, segun lo disponga el usuario?


Poca información encontré sobre este tema, y lo que encontré, no lo termine de entender... agradezco ayuda!
Saludoss!