문제

I have written a gallery plugin which uses fancybox for the popup. This all works but I have an issue where I do an ajax call and replace all the images depending on some filters.

$.ajax({
    url: this.action,
    type: this.method,
    data: $(this).serialize() + '&filter=submit&isAjax=true',
    success: function (result) {
        photoHolder.html(result);
    }
});

Now I would expect that I should have to rebind the fancybox to the new content so in my success I thought I would have had to do something like:

photoHolder.html(result);
photoHolder.find('.fancybox').fancybox();

However I have not, but the fancybox is working on the new content. Does anyone know why this is?

도움이 되었습니까?

해결책

Yes, it does work for run-time added elements.

See the "live" parameter in the docs. true is the default.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top