[jQuery] Need to assign and then track a class after browser refreshes
I like the accordion plug in, but it does not do everything that I
need. So I rebuilt everything to do what I needed it to... with one
exception.
I need to have a "last active state". By that I mean, I need to first
set and then track an active state in my accordion. Using the
jquery.cookie.js plug in, I am able to write the cookie.
However, I can't figure out the following:
1. How to track where the last click was...
2. How to reintroduce the classes assigned to that click.
I may be going about this all wrong... that's ok, it's how I learn.
So, I want to assign a class to the last a href clicked (done), add
that class to a cookie (done), then get that class back from the
cookie (done), then reassign the class to the html after refresh. (NOT
done)
Code is below. Any help would be awesome.
Dave
JS
++++++++++++++++++++
/*
* Site Settings
*
* Copyright (c) 2008 Dave Merwin
* Dependencies:
*
*/
$(document).ready(function(){
//Ultimate Sidebar Nested Accordion Menu
// Add the class for ul
$('#subNav ul').addClass('subNavMenu');
$('#subNav li').children('ul').parent().prepend('<a href=""
class="subNavToggle"><span class="close">Close</span><span class="open
mir">Open</span></a>');
var COOKIEMONSTER = $.cookie('selected');
if (COOKIEMONSTER == '' || COOKIEMONSTER == null) {
$('#subNav li').children('ul').hide();
} else if(COOKIEMONSTER == 'on') {
$('#subNav li').children('ul').hide();
$('.lastSelected').parent().children('ul').show();
alert(COOKIEMONSTER);
}
//Set nav function Buttons
$('.subNavToggle').click(function() {
$(this).parent().children('ul').slideToggle('fast');
$(this).children('span').toggle();
$(this).siblings('a').addClass('active');
$(this).addClass('closeIcon').addClass('mir');
$
(this).parent().siblings().children('ul:visible').slideUp('fast');
$.cookie('selected', 'on');
alert('Cookie Added');
return false;
});
});
++++++++++++++++++++