I'm having trouble getting jQuery to work in the .load() function.
The script loads the specified pages content into the #project div, and then initializes flexslider, which is working fine.
The problem is, I'm trying to add arrows to navigate to next/previous post, but of course if I put the .load function for the arrows outside of the first .load function below, the code won't work.
I tried putting them within the .load function below as well, and it worked fine for the first post. After that, all the jQuery stopped initializing (flexslider, and even the left/right arrow click function).
It's like I would have to do an unlimited .load() loop or something. I hope I'm making sense and hopefully somebody can help. Here's what I have that works, minus the arrows.
To sum up the question.. is there anyway to get jQuery to work in the .load() function without re-initializing it inside the .load()?
jQuery('.single-item, .portfolio-images article').click(function() {
var geturl = window.location;
var next_project = jQuery(this).attr('data-projectid');
jQuery('html, body').animate({ scrollTop: 0 }, 500);
jQuery('#project').slideUp('slow');
jQuery('#project').load(geturl + "?page_id=" + next_project + " .project", function() {
if (jQuery(this).hasClass('opened')) {
jQuery(this).slideDown(600);
jQuery('.flexslider').fadeIn();
} else {
jQuery(this).slideDown(300);
jQuery('.flexslider').fadeIn();
}
jQuery('.grid').click(function() {
jQuery('#project').slideUp(500);
});
// Initialize Scripts
jQuery('.flexslider').flexslider({
animation: "slide",
smoothHeight: true,
startAt: 0,
});
});
}).addClass('opened');
return false;