# Problem using Javascript with Ruby

**URL:** <https://www.ruby-forum.com/t/problem-using-javascript-with-ruby/133579>\
**Category:** Ruby\
**Created:** [April 1, 2008, 9:18pm UTC](https://www.ruby-forum.com/t/problem-using-javascript-with-ruby/133579 "2008-04-01T21:18:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tensaijin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/d6d6ee/32.png) [@tensaijin](https://www.ruby-forum.com/u/tensaijin)\
**Post date:** [April 1, 2008, 9:18pm UTC](https://www.ruby-forum.com/t/problem-using-javascript-with-ruby/133579/1 "2008-04-01T21:18:50Z")

</div>

Hello,

I am new to Ruby and I am currently creating a webpage which lists bug  
_stats_ information for various development teams. Each team is  
represented on the page with an image.  
When a team’s link is clicked, I want 2 things to happen:

1. Javascript needs to call the displayLogo() method to handle visual  
effects
2. Ruby needs to call the loadCustomLinks() method to display a link

Current Behavior: When a team link is clicked, the javascript effects  
appear  
and then disappear, followed by the display of the  
team’s  
custom link.

Expected Behavior: When a team link is clicked, I want the javascript  
effects  
to STAY active after the custom link is displayed.

I expect that my issue is more related to Javascript than to Ruby, but I  
also want to make sure that I am using good Ruby programming  
practices…

Any help is appreciated,

JT

`
#
home_controller.rb------------------------------------------------------------
class HomeController < ApplicationController
layout ‘mainLayout’
def index
end
def loadCustomLinks
@team_links = " Special Team Link
#1
"
end
end
javascript
(embedded)---------------------------------------------------------
function displayLogo(name)
{
// De-select last selected item
document.images[lastName].src = “/images/” + lastName + “.png”;
// Highlight team icon
document.images[name].src = “/images/” + name + “_hover.png”;
// Activate team banner
document.images[“logo”].src = “/images/logo_” + name + “.png”;
// Re-activate siteBanner (TEMP FIX)
document.images[“siteBanner”].src = “/images/logo_dashboard.png”;
// Set lastName
lastName = name;
} // end displayLogo()

#layout.rhtml
<%= link_to(image_tag(’/images/banner_team1.png’,
:id => ‘bannerImgAlign’, :name => ‘banner_team1’,
:style => ‘border:0’, :onclick => ‘displayLogo(“banner_team1”)’),
:action => ‘loadCustomLinks’) %>
`

---

<div class="post-metadata">

**Author:** ![tensaijin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/d6d6ee/32.png) [@tensaijin](https://www.ruby-forum.com/u/tensaijin)\
**Post date:** [April 1, 2008, 11:32pm UTC](https://www.ruby-forum.com/t/problem-using-javascript-with-ruby/133579/2 "2008-04-01T23:32:37Z")

</div>

Jt Taylor wrote:

> I expect that my issue is more related to Javascript than to Ruby, but I  
> also want to make sure that I am using good Ruby programming  
> practices…

I’m guessing that when you say “Ruby” you mean “Ruby on Rails,” in which  
case the RoR mailing list is going to be more helpful than this list.  
Ruby is a general purpose programming language. Ruby on Rails is a web  
application framework written in Ruby.

Check [Ruby on Rails — Community](http://www.rubyonrails.com/community) to find out more about the  
RoR mailing list.

Good luck!

---

<div class="post-metadata">

**Author:** ![tensaijin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/d6d6ee/32.png) [@tensaijin](https://www.ruby-forum.com/u/tensaijin)\
**Post date:** [April 1, 2008, 11:35pm UTC](https://www.ruby-forum.com/t/problem-using-javascript-with-ruby/133579/3 "2008-04-01T23:35:51Z")

</div>

Tim H. wrote:

> Jt Taylor wrote:
> 
> > I expect that my issue is more related to Javascript than to Ruby, but I  
> > also want to make sure that I am using good Ruby programming  
> > practices…
> 
> I’m guessing that when you say “Ruby” you mean “Ruby on Rails,” in which  
> case the RoR mailing list is going to be more helpful than this list.  
> Ruby is a general purpose programming language. Ruby on Rails is a web  
> application framework written in Ruby.
> 
> Check [Ruby on Rails — Community](http://www.rubyonrails.com/community) to find out more about the  
> RoR mailing list.
> 
> Good luck!

Ah, didn’t know that, thanks!
