neharohan.chopra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Feb-26 22:17 UTC
button_to_function with text and image
Hi, Is there a way to have text as well as image u the button_to_function. <%= button_to_function "Cancel" , "#{remote_function()}"%> I have something like this and now i want the cancel should also have some text with it. Neha --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
http://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html#M001062 113: def button_to_function(name, *args, &block) 114: html_options = args.extract_options! 115: function = args[0] || '''' 116: 117: html_options.symbolize_keys! 118: function = update_page(&block) if block_given? 119: tag(:input, html_options.merge({ 120: :type => "button", :value => name, 121: :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};" 122: })) 123: end See the source. Although I am not quite understand it, I am sure that the only way with which you can do this is using javascript in ''onclick'' event, if there does exist a way. But if you want text and image before click, I think you''d better write html on your own. On Feb 27, 6:17 am, "neharohan.cho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <neharohan.cho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > Is there a way to have text as well as image u the button_to_function. > <%= button_to_function "Cancel" , "#{remote_function()}"%> > > I have something like this and now i want the cancel should also have > some text with it. > > Neha--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
neharohan.chopra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Feb-29 18:13 UTC
Re: button_to_function with text and image
yeah thats the approach i had to follow :) On Feb 28, 9:33 pm, hei <cy...-KN7UnAbNpbg@public.gmane.org> wrote:> http://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelpe... > 113: def button_to_function(name, *args, &block) > 114: html_options = args.extract_options! > 115: function = args[0] || '''' > 116: > 117: html_options.symbolize_keys! > 118: function = update_page(&block) if block_given? > 119: tag(:input, html_options.merge({ > 120: :type => "button", :value => name, > 121: :onclick => (html_options[:onclick] ? > "#{html_options[:onclick]}; " : "") + "#{function};" > 122: })) > 123: end > See the source. > Although I am not quite understand it, I am sure that the only way > with which you can do this is using javascript in ''onclick'' event, if > there does exist a way. > But if you want text and image before click, I think you''d better > write html on your own. > > On Feb 27, 6:17 am, "neharohan.cho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > > <neharohan.cho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, > > > Is there a way to have text as well as image u the button_to_function. > > <%= button_to_function "Cancel" , "#{remote_function()}"%> > > > I have something like this and now i want the cancel should also have > > some text with it. > > > Neha--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---