tamriel-foundry / apocrypha

Theme files for Tamriel Foundry
2 stars 1 forks source link

AJAX pagination and post loading for home-page and archive loops #1

Closed aaclayton closed 11 years ago

aaclayton commented 11 years ago

It would be great AJAX-ify the front page posts loop for a nice seamless browsing experience.

aaclayton commented 11 years ago

I took a first pass at this, it's looking promising, but not there yet. I'm getting the new posts just fine, and it looks great. I'm running into problems when trying to update the pagination links to reflect the page change.

aaclayton commented 11 years ago

I thought I had made some great progress here, but I've got some kind of crazy issue where my jQuery is firing multiple times. I think it's because I'm targeting click handlers by class, so there are multiple elements in the DOM which have the click event...maybe? I don't know. I may need @jaspervalero to give me a hand figuring this one out.

aaclayton commented 11 years ago

OK, I figured out my problem! It wasn't that the click event was running multiple times. The problem was that a jQuery method that removed existing posts had a callback to do some other stuff once the existing posts were gone. Since I was matching on the .post class, the callback was running FOR EVERY post, and therefore duplicating all my AJAX responses. TRICKY!

I learned about the jQuery .promise() method and am using it as a way to defer loading new posts into the DOM until after all the existing posts are gone.

aaclayton commented 11 years ago

Big victory on this. Working as intended on all browsers! Please test it out once I push changes.