jQuery UI: Update image source inside jquery dialog after dialog has been opened
I have the following function:
function imageSwap(imgPath){
jQuery("#bigimage").attr("src", imgPath);
}
which is called by:
<a href="#" onmouseover="imageSwap('images/upload_pic/resize_<?php echo $image->image;?>')">
<img src="images/upload_pic/thumbnail_<?php echo $image->image; ?>" border="0">
</a>
The basic idea is that when you mouseover the thumbnail, it calls the function that replaces the src of image element "big开发者_如何学Cimage""
<div class="popup_image">
<img src="images/upload_pic/resize_<?php echo $bigimage; ?>" id="bigimage">
</div>
Thus far, it works well inside normal HTML.
The problem is that I have this inside a jQuery UI .dialog.
And then it does not update "bigimage"
Any ideas?
Thanks guys
Possibly because it's in an iframe and the reference to #bigimage is not within it's scope?
Try using
function imageSwap(imgPath){
jQuery("#bigimage", window.parent.document).attr("src", imgPath);
}
Providing the code is accessible from within the iframe, you might have to move that within it.
精彩评论