Event.observe(window, 'load', function() { $$('.thumbnails img').each(
function (thumb) { Event.observe(thumb, 'click',changeImage); }); });You are assigning a click event to the thumbnail div which is not an img tag- the above code will assign the click event to all the thumbnails in the div. On 3/21/07, OmenKing <[EMAIL PROTECTED]> wrote: > > > what do you think my problem with my code is? > > On Mar 18, 1:30 pm, "OmenKing" <[EMAIL PROTECTED]> wrote: > > gallery.html > > > =================================================================================================== > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " > http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > > <html xmlns="http://www.w3.org/1999/xhtml"> > > <head> > > <title>Cruise Beautiful Lake Temagami</title> > > <meta http-equiv="content-type" > content="text/html;charset=utf-8" /> > > <meta name="generator" content="NotePad++" /> > > <link href="css/basic.css" rel="stylesheet" > type="text/css" > > media="all" /> > > <script type="text/javascript" > src="scripts/prototype.js"></script> > > <script type="text/javascript" > src="scripts/main.js"></script> > > </head> > > <body> > > <div class="container"> > > <div class="header"><h1><span>Cruise > Beautiful</span></h1></ > > div><!-- header --> > > <div class="navigation"> > > <ul> > > <li><a href="index.html > ">About</a></li> > > <li><a href="gallery.html" > class="active">Gallery</a></li> > > </ul> > > </div><!-- navigation --> > > <div class="content_wrap"> > > <div class="content"> > > <a id="clicker" href="gallery.html">Click me</a> > > <div class="thumbnails" id="thumbnails" > > > <img src="images/thumbnail_houseboat_00.gif" alt="" > id="houseboat_00" > > onClick="changeImage()" /> > > <img src="images/thumbnail_houseboat_01.gif" alt="" > > id="houseboat_01" /> > > <img src="images/thumbnail_houseboat_02.gif" alt="" > > id="houseboat_02" /> > > <img src="images/thumbnail_houseboat_03.gif" alt="" > > id="houseboat_03" /> > > <img src="images/thumbnail_houseboat_04.gif" alt="" > > id="houseboat_04" /> > > <img src="images/thumbnail_houseboat_05.gif" alt="" > > id="houseboat_05" /> > > </div><!-- thumbnails --> > > <img src="images/houseboat_00.gif" alt="" id="display" /> > > > > </div><!-- content --> > > </div><!-- content_wrap --> > > <div class="footer"><p>©2007 Cruise > Beautiful</p></div><!-- > > footer --> > > </div><!-- container --> > > </body> > > </html> > > > =================================================================================================== > > > > main.js > > > =================================================================================================== > > /* function change_image(index) > > { > > this.src = "images/houseboat_00" > > $('display').src = "images/houseboat_" + index + ".gif"; > > path = 'houseboat_' + index; > > $(path).className = "active"; > > > > }; */ > > > > // function change_image(event) > > // { > > // var element_tag = Event.element(event); > > // if (element_tag.tagName != 'img') > > // return; > > // Event.stop(event); > > // $('display').src = "images/" + element_tag.id + ".gif"; > > // $(element_tag).addClassName('active'); > > // } > > > > // Event.observe(window, 'load', > > // function() > > // { > > // $('thumbnails').observe('click', change_image); > > // } > > // ); > > > > function changeImage(e) { > > var elt = Event.element(e); > > if (elt.tagName != 'IMG') > > return; > > Event.stop(e); > > $('display').src = "images/" + elt.id + ".gif"; > > $(elt).addClassName('active'); > > > > } > > > > Event.observe(window, 'load', function() { > > $('thumbnails').observe('click', changeImage); > > > > }); > > > > //Event.observe('clicker', 'click', function(event) > > { alert('clicked!');}); > > > =================================================================================================== > > > > On Mar 18, 12:00 pm, Christophe Porteneuve <[EMAIL PROTECTED]> wrote: > > > > > You must not have used the whole setting. Maybe you used an inline > handler? > > > > > You should post a minimal reproduction online so we can get the whole > > > picture on how you use this stuff, and tell you exactly what needs > > > adjustment. > > > > > -- > > > Christophe Porteneuve a.k.a. TDD > > > "[They] did not know it was impossible, so they did it." --Mark Twain > > > Email: [EMAIL PROTECTED] > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
