So what I'm trying to do is append content from an HTML document to a DIV that I've already loaded content into (from the same file) using AJAX.
I'm trying to have it so when you click the "previous" and "next" buttons it loads the previous or next project.
Here's what I have for code.
HTML (I'm loading content into #ajax)
<div class="p-modal">
<div id="p-controls">
<a id="p-close" href="javascript:;">Close</a>
</div>
<div id="ajax"></div>
</div>
jQuery
$(document).ready(function() {
$('.p-load').on('click', function(e) {
e.preventDefault();
var href = $(this).attr('href');
if ($('#ajax').is(':visible')) {
$('#ajax').css({ display:'block' }).animate({ height:'auto' }).empty();
}
$('#ajax').css({ display:'block' }).animate({ height:'auto' },function() {
$('#ajax').html('<img id="loader" src="images/loading.gif" width="48" height="48">');
$('#loader').css({ border:'none', position:'absolute', top:'50%', left:'50%', margin:'-24px 0 0 -24px', boxShadow:'none' });
$('#ajax').load('includes/projects.html ' + href, function() {
$('#ajax').hide().fadeIn('slow');
});
});
});
});
DEMO (Scroll down to the "Work" section — it works to load each project individually if you open a project and then close it, but when I use the same code above on the "prev" and "next" triggers inside the project popup, it doesn't do anything)
Any help is greatly appreciated!