I have a home template with a header, footer and a left sidebar.
<?php get_header(); ?>
<div class="content">
<?php get_sidebar('left'); ?>
<div class="middlebar">
this is the main content
</div>
</div>
<?php get_footer(); ?>
After a click on one of the multiple options of the menu, the page template is loaded which has an additional right sidebar.
<?php get_header(); ?>
<div class="content">
<?php get_sidebar('left'); ?>
<div class="middlebar">
pagecontent
</div>
<?php get_sidebar('right'); ?>
</div>
<?php get_footer(); ?>
I animated this sidebar, that it slides in after the page is loaded.
jQuery(window).ready(function($){
$("#sidebarRight").animate({right: '0px'});
});
My problem now is that the animation is played on every click on one of the menu points. So after a click on a link, the sidebar disappears only to reappear again. I want that the animation is just played once when the user leaves the home template and enters the page template (by clicking one of the menu points) and not during switching between the different pages.
My first idea was to change the middlebar div
with every click.
So that not the whole page template is reloaded but just the new content is loaded and inserted in the div.
A positive side effect would be that fewer data has to be loaded, but I was not able to prevent the multiple loading of the sidebar.
I also tried to set cookies, but that worked neither.
How can I load the sidebar only at the first click, so that the animation is also played just once.