On Jun 6, 2011, at 2:46 PM, Rodrigo Ruiz wrote: > Hi, I'd like to know how can I make a link to a method. I mean, not a link > that would normally render a new page, but something that looks like a link > (a blue word) but triggers one of my class methods like show a photo at the > right side of my website or hide it if clicked again. > > Thank you
For this you would normally use JavaScript. I'd recommend reading up at Mozilla Developer Network: https://developer.mozilla.org/en-US/learn. Basically you'll register an 'onclick' handler on the link and in that function, change the display style of the photo. For instance: HTML: > <script type="text/javascript" src="/javascripts/index.js"></script> > ... > <a href="#" id="show-link">Show Picture</a> > ... > <img src="/images/me.jpg" id="my-picture" /> JavaScript (index.js): var link = document.getElementById("show-link"); if (link) { link.onclick = function(event) { var picture = document.getElementById("my-picture"); if (picture) { if (picture.style.display == "none") { picture.style.display = "inline"; } else { picture.style.display = "none"; } } }; } -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" 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-talk?hl=en.

