开发者

jQuery UI: Update image source inside jquery dialog after dialog has been opened

开发者 https://www.devze.com 2023-01-26 12:16 出处:网络
I have the following function: function imageSwap(imgPath){ jQuery(\"#bigimage\").attr(\"src\", imgPath);

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.

0

精彩评论

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

关注公众号