Skip to content Skip to sidebar Skip to footer

Prettyphoto Wont Load When Writing Href Using Document.write

i have some codes like this click function menu(id){ var d = document.getElementB

Solution 1:

And it is not going to work this way. You initialize prettyPhoto for existing elements on the page after your page was loaded. When you insert a new element, prettyPhoto plugin knows nothing about it, because it already "attached" itself to the elements existed before. You have to initialize prettyPhoto after all changes on the page or attach it after changes to the updated elements. Like this

function menu(id){ 
var d = document.getElementById(id); 
d.innerHTML ='<a href="somthing;iframe=true&amp;width=400&amp;height=170"  rel="prettyPhoto[iframe]" >Doesnt work</a>';
$('a', d).prettyPhoto({theme:'h0mayun'});
}

ps: I've made a simple test with the example of prettyPhoto and it is working

function menu(id){ 
var d = document.getElementById(id); 
d.innerHTML ='<a href="images/fullscreen/3.jpg" rel="prettyPhoto[gallery1]">Test link</a>';
$('a', d).prettyPhoto();
}

Solution 2:

If you're doing this $(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'h0mayun'}); before the onClick function.

You would have to do it again after you have written the html of the object so the plugin would initialize again.


Post a Comment for "Prettyphoto Wont Load When Writing Href Using Document.write"