Doing a thing only once another thing is complete
Hello everybody,
I hope it is okay to ask for help with Mootools here.
I am using Fx.Slide to get the main content of my page to slide in when the DOM is ready. Then when someone clicks on a link to go to a different page I want the main content to slide out before the browser changes location.
Here is the HTML for example:
HTML Code:
<ul id="menu">
<li><a href="page2.html">Page 2</a></li>
</ul>
<div id="mainContent">content here!</div>
I have been able to get 'mainContent' to slide in when the DOM is ready and I can get the the content to slide out when 'menu' is clicked OR to get the window to change location when 'menu' is clicked but I can't get both things to happen. Does anyone know how to I edit my javascript so that the window changes location only when the slide out is complete?
Here's an example of the javascript I've written:
Code:
window.addEvent('domready', function(){
var myPanal = new Fx.Slide('mainContent').hide();
myPanal.slideIn();
$('menu').addEvent('click', function(e){
myPanal.slideOut();
myPanal.addEvent('complete', function() {
window.location="../page2.html/";
});
});
});
Thanks for any help!