Invoking MouseOver using link_to tag?

Hi,

How can we trigger a JavaScript built in function from a <%= link_to %>
ie. i have the below statement in my view. I want to invoke a JavaScript
function on “MouseOver” of this below text (‘TestingMouseOverEvents’).

<%= link_to “TestingMouseOverEvents” , :controller => “login”, :action
=> “logout”%>

Note: The controller and action should also be there as above. ie invoke
the controller function on click of the link and invoke a local JS
function on MouseOver of the text ?

On a normal href we do something like this rt? for invoking the
onMouseover and onMouseout?. But i want to do the same thing but with
<%= link_to %> as above ?

TestingMouseOverEvents

Thank You
Dinesh

I guess we can do it as below…

<%= link_to “Test” , “http://www.google.com” , :onMouseover =>
“alert(‘hello’)” , :controller => “login”, :action => “logout”%>

Thanks,
Dinesh

Dinesh U. wrote:

Hi,

How can we trigger a JavaScript built in function from a <%= link_to %>
ie. i have the below statement in my view. I want to invoke a JavaScript
function on “MouseOver” of this below text (‘TestingMouseOverEvents’).

<%= link_to “TestingMouseOverEvents” , :controller => “login”, :action
=> “logout”%>

Note: The controller and action should also be there as above. ie invoke
the controller function on click of the link and invoke a local JS
function on MouseOver of the text ?

On a normal href we do something like this rt? for invoking the
onMouseover and onMouseout?. But i want to do the same thing but with
<%= link_to %> as above ?

TestingMouseOverEvents

Thank You
Dinesh

<%= link_to “TestingMouseOverEvents” , {:controller => “login”, :action
=> “logout”}, {“onmouseover” => “jscode”, “onmouseout” => “jscode”}%>

Having some difficulty doing this, I want to run a .rjs template on the
mouseover event to show a hidden div, (and another on the mouse off to
hide it) tho 'cause I have a block in to hide visible menus when one is
removed I don’t think I can put my stcript in the link.

Basically I can’t find a way to reference the RJS template as part of
the mouseover event.

Bojan M. wrote:

Add to Html options, like:

<%= link_to “TestingMouseOverEvents” , {:controller => “login”, :action
=> “logout”}, {“onmouseover” => “jscode”, “onmouseout” => “jscode”}%>

Bojan M.

Or better yet, don’t. Use an external
JS file and set the handlers there. JavaScript works best when it’s
kept completely separate from HTML.

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

Add to Html options, like:

<%= link_to “TestingMouseOverEvents” , {:controller => “login”, :action
=> “logout”}, {“onmouseover” => “jscode”, “onmouseout” => “jscode”}%>

Bojan M.

Dinesh U. wrote:

Note: The controller and action should also be there as above. ie invoke

Thank You
Dinesh


Bojan M.
Informatika Mihelac, Bojan M. s.p. | www.informatikamihelac.com
→ tools, scripts, tricks from our code lab: http://source.mihelac.org