0

I am loading in page content via ajax, I am wanting the old content to slide up to the top dissapear, and the new content to follow it into position, my problem is that I cannot seem to get the new content to animate, it just renders on the button click (the old content does however animate). Below is my javascript,

$("#ajax").live("click", function(e){
    var loadURL = $(this).attr('href');
    $("#information").animate{{positionTop : "-900px" }, 1000);
    $(".content").load(loadURL + " #information").animate({positionTop: "0px"}, 1000);
    e.preventDefault();
});

Here is my HTML markup,

<div class="content">
    <div class="loading"></div>
    <article id="information">
        <header>
            <h1 class="beta"></h1>
            <a href="" class="learn">Learn More</a>
        </header>
        <section class="advantage">

        </section>
        <section class="advantage">

        </section>
        <section class="advantage">

        </section>
        <a class="next-advantage" id="ajax" href="/logic-combi.php">Logic+ Combi</a>
    </article>
</div>

The JS is requesting exactly the same setup of HTML, but only from <article id="information">

0

2 Answers 2

2

Perform the animation in the callback of the load function.

$(".content").load(loadURL + " #information", function(){
  $('#information').animate({positionTop: "0px"}, 1000);
});
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect. It really helped. :)
0

positionTop isn't a valid paramater for animate, you may want to use scrollTop.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.