Pergunta

I would like to initialize prettyPhoto plugin for multiple galleries on one page so they can be shown separately. My idea was to go through all the divs which contain pictures and initialize new prettyPhoto for all images in that div. But val is apparently some kind of object and I am not able to call any functions on it. Is there a way how to do what I need?

 $(document).ready(function() {
     $.each($(".gallery"), function(i, val) {
         $(val).find("img").prettyPhoto({}); //init prettyPhoto plugin
     });
 });

P.S. Sorry for lame question I suppose it's basic stuff.

Foi útil?

Solução

I finally found the solution in case anybody is interested.

 $(document).ready(function(){
        $.each($(".gallery"), function(i, val) {
            var queryString = ".gallery:nth(" + i + ") a[rel^='prettyPhoto']";
            $(queryString).prettyPhoto({animation_speed:'normal',theme:'light_square', social_tools: false});
        });
    });
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top