0

Hi, I need help!
Im updating a div with groups of images using jquery ajax.
I'm also using the Galleria plugin to display these images. My problem is this: on the first set of images loaded galleria works fine, but if i try to load differnt images galleria does not load again and the image just get placed in the div!

this is my jquery ajax that loads the images in

// whenever a link with category class is clicked
$('a.project').click(function(e) {
    // first stop the link to go anywhere
    e.preventDefault();
    // you can get the text of the link by converting the clicked object to string
    // you something like 'http://mysite/categories/1'
    // there might be other methods to read the link value
    var linkText = new String(this);
    // the value after the last / is the category ID
    var projectvalue = linkText.substring(linkText.lastIndexOf('/') + 1);
    // send the category ID to the showprojects.php script using jquery ajax post method
    // send along a category ID
    // on success insert the returned text into the shownews div
    if($('#shownews').data('galleria')){$('#shownews').data('galleria').destroy()} //destroy, if allready running
$.post('../inc/showprojects.php', {project: projectvalue}, function(data) {
    $('#shownews').html(data);
    Galleria.run('#shownews');
});


});

Can anyone help me out with this?

Thanks

2
Contributors
2
Replies
20
Views
4 Years
Discussion Span
Last Post by GlenRogers
0

Assuming your a.project content is inside your #shownews, you should use $('a.project').on('click', function(e){...}); instead of the click function, since it will only work for the content you load the first time, and is not binded to dynamically created objects.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.