how to use a javascript funtion which should run when i am clicking any link or submit in whole form? except in onclick tag (or) on submit tag -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Pokkai Dokkai wrote:> how to use a javascript funtion which should run when i am clicking any > link or submit in whole form? > except in onclick tag (or) on submit tagdon''t get, what exactly you want to do link_to_function "Greeting", "alert(''Hello world!'')" would create a link to a js function otherwise you can implement onclick whereever necessary: onclick="alert(''Hello world!'');return false;" or combine it with onsubmit etc. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller wrote:> Pokkai Dokkai wrote: >> how to use a javascript funtion which should run when i am clicking any >> link or submit in whole form? >> except in onclick tag (or) on submit tag > > don''t get, what exactly you want to do > > link_to_function "Greeting", "alert(''Hello world!'')" > would create a link to a js function > > otherwise you can implement onclick whereever necessary: > onclick="alert(''Hello world!'');return false;" > > or combine it with onsubmit etc.i want to do if there is any button or link is clicked then a javascript function should automatically execute -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Pokkai Dokkai wrote:> Thorsten Mueller wrote: >> Pokkai Dokkai wrote: >>> how to use a javascript funtion which should run when i am clicking any >>> link or submit in whole form? >>> except in onclick tag (or) on submit tag >> >> don''t get, what exactly you want to do >> >> link_to_function "Greeting", "alert(''Hello world!'')" >> would create a link to a js function >> >> otherwise you can implement onclick whereever necessary: >> onclick="alert(''Hello world!'');return false;" >> >> or combine it with onsubmit etc. > > i want to do if there is any button or link is clicked then a javascript > function should automatically executesimple with jQuery ! jQuery(''a'').click(function(){ my nice code here }); although, getting jQuery working with prototype is bit tricky. i use jrails javascript files, but WITH prototype. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think the prototype equivalent is $$(''a'').onclick = function(){ } however I am also more partial to the JQuery way. I have yet to have a problem making them work together. Just get this order right and you should be fine: include jQuery call "var J = jQuery.noConflict()" include prototype J(''a'').click(function(){}) -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---