I'm using the following code to show the sidebar when .sidebar-toggle is pressed, and hide the sidebar when #page is pressed.
Showing the sidebar works perfect, but it doesn't hide when #page is being pressed. It looks like the variable isn't set to 1 when the .sidebar-toggle has been clicked.
var state = 0;
if (state === 0) {
$('.sidebar-toggle').click(function() {
$('#page').animate({marginLeft: '230px'}, 400);
state = 1;
});
}
if (state === 1) {
$('#sidebar').click(function() {
$('#page').animate({marginLeft: '0'}, 400);
state = 0;
});
}