开发者

how can i open another prettyphoto window using a link which is located inside the parent prettyphoto window?

I have html table wich is constructed in the server side using AJAX. This html table is shown using prettyphoto, everything is ok until here. But the last collumn of the table is a link which calls a image which should be opened using prettyphoto too, but this link is not working like i expect. It opens the image without the prettyphoto. See the code below :

--> The function which uses AJAX and open the table inside prettyphoto

function myJS(myVar){

if (window.XMLHttpRequest){

xmlhttp=new XMLHttpRequest();}

else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}

xmlhttp.onreadystatechange=function(){

if (xmlhttp.readyState==4 && xmlhttp.status==200){

var description = xmlhttp.responseText;

$.prettyPhoto.open('#inline-1',myVar, description);

}

}

xmlhttp.open("GET","return_form.php?q="+escape(myVar),true);

xmlhttp.send();

}

// Here is the div used by prettyphoto

<div id="inline-1" class="hide"></div>

------> The way a set up prettyphoto

$(document).ready(function(){

$.fn.prettyPhoto();

$("a[rel^='prettyPhoto']").prettyPhoto();

});

--> And the way i am calling prettyphoto again inside the table returned by ajax in parent prettyphoto, which is not working. When i click in the link, It is opened in a normal way without prettyphoto

<td><a href='Habilitacao.jpg' rel='prettyPhoto' title='This is the description'><img src='nf_logo.jpg' width='30' height='30' alt='This is the title' /></a></td>

Would be good, if the link in the table open the image in a next window and when i click in the previous button of the image opened, it will go back to the first one which i have the table with lots of links.

Or if it i开发者_Python百科s not possible the first option, just open the link in another window using prettyphoto and when i close the image window, i can go back to the table window where there are one link for each row.

Thanks,


I don't think the $.prettyPhoto.open() function is doing what you expect it to do. The function expects an image name as a string, an image title, and an image description, but you're passing it an id, a variable, and your entire ajax response.

Try something like this:

$(xmlhttp.responseText).find('a[rel^="prettyPhoto"]').prettyPhoto();

Replace what's currently in your "if (xmlhttp.readyState==4 && xmlhttp.status==200)" block with the above code, and I think that should work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜