I don''t see why you need ajax for this. Unless you plan on doing some
funky things on the server side, just do everything in JavaScript. The
code below is from DevLists and it can be modified to do exactly what
your asking for.
<html>
<head>
<script src="/javascripts/prototype.js"
type="text/javascript"></script>
<script>
function toggle() {
if ($(''main_img'').src.search(/\/images\/flag-on.gif/i)
!= -1)
$(''main_img'').src =
''/images/flag-off.gif'';
else
$(''main_img'').src =
''/images/flag-on.gif'';
}
</script>
</head>
<body>
<img id="main_img" src="/images/flag-on.gif"
onclick="toggle();"/>
</html>
Simply have a convention that all main images are named the same as
thumbnails, except for a _thm suffix; then use JS to strip the _thm
suffix and set the result as the src on the main image. Doing it this
way will have side benefits: one less http request, faster user
response, and once the browser caches the images users can switch the
main image with zero http requests.
HTH.
On Tuesday, March 14, 2006, at 5:03 PM, szymek wrote:>Hi!
>
>On my page i display one full size image and a list of thumbnails.
>I''d like to change the full size image with a full size version of
a
>thumbnail, after clicking on one of them.
>
>How to write controller action, so it would update the image without
>reloading the whole page? It''s easy with text, but how to reload an
>image?
>
>--
>Posted via http://www.ruby-forum.com/.
>_______________________________________________
>Rails mailing list
>Rails@lists.rubyonrails.org
>http://lists.rubyonrails.org/mailman/listinfo/rails
Cheers!
--Dave Teare
http://devlists.com - Email list management
http://palmsphere.com - Apps for your hand-held
--
Posted with http://DevLists.com. Sign up and save your time!