Adding script behavior to Navigation menu

Topics: General
Aug 2, 2013 at 2:20 PM
Edited Aug 2, 2013 at 2:20 PM
I want to do some JQuery UI animation before transitioning to another page.
Is there anyway I can manipulate the Navigation onClick somehow to add my own function call?

My function will contain something like this:
    $("#content").animate({"height": newHeight,}, 1000, function () {
        window.location = url; //move to new page *after* animation ends
    });  
Developer
Aug 5, 2013 at 6:36 AM
Did you try to bind a handler with the "click" event of the navigation items in question?
e.g.
$("nav").on("click", "li > a", function(e){
   var url = $(this).attr("href");
   $("#content").animate({"height": newHeight,}, 1000, function () {
        window.location = url; //move to new page *after* animation ends
    }); 
   e.preventDefault();
});