rails, prototype, preload remote called pictures
I'm using periodic_remote_ca开发者_如何转开发ll and it updates a div with pictures.
How Can I get these pictures to be preloaded?
I do not know hwether you still need the information, but you can indeed make a dynamic piece of JavaScript containing the ids, which you can use for your preload. Your View would contain something like this (assuming that @photo_ids
is the Ruby array):
<script type="text/javascript">
var photo_ids = new Array(%< @photo_ids.join(", ") %>);
</script>
Now you can loop your photos_id
in JavaScript to preload the images.
var myimage = new Image;
myimage.src = "/images/myimage.jpg";
精彩评论