Problem using Javascript with Rails

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

<code>

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...

It is just the way things works: the browser calls your javascript
function and since it doesn't return an appropriate value it proceeds
onto the default action (load the page specified). Since the page
loads any temporary javascript changes you made to the page are blown
away.
If you're want to do things like this you can drop the javascript
completely. Just make your loadCustomLinks view display the right
images.

Fred

Frederick Cheung wrote:

2) Ruby needs to call the loadCustomLinks() method to display a link

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...

It is just the way things works: the browser calls your javascript
function and since it doesn't return an appropriate value it proceeds
onto the default action (load the page specified). Since the page
loads any temporary javascript changes you made to the page are blown
away.
If you're want to do things like this you can drop the javascript
completely. Just make your loadCustomLinks view display the right
images.

Fred

Ok, that makes sense...

However you say an appropriate value is not returned, and I thought
using 'return false;' would essentially ignore the redirect action,
which it doesn't...

Also, I see 2 ways I can proceed with your suggestion:

1) Invoke the javascript method(s) through my loadCustomLinks method
2) Translate the javascript code to ruby code and place it in
loadCustomLinks

...I don't think there is a straight-forward way to do #1 without adding
plugins
I would rather do #2 as it seems a better alternative. Could you help me
get started with how to write the code for this method?

Frederick Cheung wrote:

2) Ruby needs to call the loadCustomLinks() method to display a link

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...

It is just the way things works: the browser calls your javascript
function and since it doesn't return an appropriate value it proceeds
onto the default action (load the page specified). Since the page
loads any temporary javascript changes you made to the page are blown
away.
If you're want to do things like this you can drop the javascript
completely. Just make your loadCustomLinks view display the right
images.

Fred

Ok, that makes sense...

However you say an appropriate value is not returned, and I thought
using 'return false;' would essentially ignore the redirect action,
which it doesn't...

It will but you'd have to say onclick="displayLogo(...); return false"
or "return displayLogo(...)" and have displayLogo return false

Also, I see 2 ways I can proceed with your suggestion:

1) Invoke the javascript method(s) through my loadCustomLinks method
2) Translate the javascript code to ruby code and place it in
loadCustomLinks

...I don't think there is a straight-forward way to do #1 without
adding
plugins

Well you could do 1, but honestly I don't see the point

I would rather do #2 as it seems a better alternative. Could you
help me
get started with how to write the code for this method?

Well your link will need to pass through the parameter used. Then in
your layout/view it's just a case of using that parameter (probably
assigned to an instance variable first) to make all those links to the
various images.

Fred