Re-initialise jquery on ajax loaded content
Hi, I am loading a gallery dynamically using ajax. I know i need to re-initialise the photoswipe lightbox after the ajax content is loaded. I am new to combining these things. If anyone can help with how to re-initialise the photoswipe jquery when the ajax content is loaded that would be great.
Thanks in advance
Richard
- $(function() {
- //More Button
- $('.more').live("click",function()
- {
- var ID = $(this).attr("id");
- if(ID)
- {
- $("#more"+ID).html('<img src="moreajax.gif" />');
- $.ajax({
- type: "POST",
- url: "Ajax_more_demo.asp",
- data: "lastmsg="+ ID,
- cache: false,
- success: function(html){
- $("ul#Gallery").append(html);
- $("#more"+ID).remove();
- }
- });
- }
- else
- {
- $(".morebox").html('The End');
- }
- return false;
- });
- });
-
- (function(window, PhotoSwipe){
-
- document.addEventListener('DOMContentLoaded', function(){
-
- var
- options = {
-
- getImageMetaData: function(el){
- return {
- relatedUrl: el.getAttribute('data-related-url')
- }
- }
-
- },
- instance = PhotoSwipe.attach( window.document.querySelectorAll('#Gallery a'), options );
-
-
- instance.addEventHandler(PhotoSwipe.EventTypes.onTouch, function(e){
-
- if (e.action === 'tap'){
- var currentImage = instance.getCurrentImage();
- window.open(currentImage.metaData.relatedUrl);
- }
-
- });
-
-
- }, false);
-
-
- }(window, window.Code.PhotoSwipe));
-
-
-
-
-
-