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 ? <a href="http://www.mywebsite.com" onMouseover="myInJsFunction()" onMouseout="myOutJSFunction()">TestingMouseOverEvents</a><br /> Thank You Dinesh -- Posted via http://www.ruby-forum.com/.
Add to Html options, like: <%= link_to "TestingMouseOverEvents" , {:controller => "login", :action => "logout"}, {"onmouseover" => "jscode", "onmouseout" => "jscode"}%> Bojan Mihelac Dinesh Umanath 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 ? > > <a href="http://www.mywebsite.com" onMouseover="myInJsFunction()" > onMouseout="myOutJSFunction()">TestingMouseOverEvents</a><br /> > > Thank You > Dinesh >-- Bojan Mihelac Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com -> tools, scripts, tricks from our code lab: http://source.mihelac.org
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 Umanath 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 ? > > <a href="http://www.mywebsite.com" onMouseover="myInJsFunction()" > onMouseout="myOutJSFunction()">TestingMouseOverEvents</a><br /> > > Thank You > Dinesh-- Posted via http://www.ruby-forum.com/.
> <%= 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. -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Bojan Mihelac wrote:> Add to Html options, like: > > <%= link_to "TestingMouseOverEvents" , {:controller => "login", :action > => "logout"}, {"onmouseover" => "jscode", "onmouseout" => "jscode"}%> > > Bojan MihelacOr 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 marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.