I am trying to manipulate some elements after I load them using .load(). I have everything loading correctly, but I can't seem to target any elements within any of the loaded elements. This seems like something that would be easy, but I just can put my finger on it.
I am using a callback after the elements load, but the DOM seems to not be aware of their existence?
function load_page(){
$('#page_name').load("/page-name/ .page", null, load_complete());
}
function load_complete() {
$('#page_name .book_img').addClass('hello');
}
[EDIT]
Ok, this is where I am at now. I have added...
$('#wrapper').ajaxComplete(function() {
$('#page_name .book_img').addClass('hello');
}
which works. There must be a difference between the .autoComplete and the callback which is packaged with the .load() function. I don't really like this because it is called every time an ajax event is finished loading, but it does get me a little further down the road.
Anybody have anything better?
[EDIT]
I also tried...
$('#wrapper').ajaxComplete(function() {
$('#page_name .book_img').addClass('hello');
}
Which is kind of nice since it waits till all ajax calls are done before calling the function. Maybe this is the way to do it, but it still seems like the .load() function would take care of this?