Hi, I''m using standard Rails form builder form_for and haml. I''m trying to replace standard Rails submit button with an image. In addition Javascript runs on submit event. How can I replace the f.submit button by an image-based button? -------- remote_form_for(@message, :html => {:onsubmit => "jQuery(<code>)"}) do |f| = f.error_messages %table - #... regular form fields with some more indentation ... = f.submit ''Send It'' -# I thought this might work, but onsubmit event is not firing. Plus it''s a security bomb if JS is disabled in browser. = link_to image_tag(''message_send.png''), :action => ''create'', :method => :post, :id => @message -------- Would really appreciate your help. Thank you, Michael -- 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.
Christophe Decaux
2010-Mar-11 09:53 UTC
Re: using image_tag as submit button inside form_for block
I don''t know much about haml, but I wanted the same thing than you. Here''s what I did <% form_remote_tag( :url=>{:action=>''moderate'', :controller=>''messages''}, :html=>{:id=>''new_message_form''}, :complete=>"Form.reset(''new_message_form'')") do %> <%= hidden_field_tag ''whatever'' %> <p> Text<br /> <%= text_area ''message'', ''text'', :rows=>3 %> </p> ...... <p> <%= image_submit_tag "button.png", :name => "submit", :onClick => "some JS here" %> </p> <% end %> Hope this helps, Christophe Le 11 mars 2010 à 06:27, Liberty1776 a écrit :> Hi, > > I''m using standard Rails form builder form_for and haml. > I''m trying to replace standard Rails submit button with an image. > In addition Javascript runs on submit event. > How can I replace the f.submit button by an image-based button? > -------- > remote_form_for(@message, :html => {:onsubmit => "jQuery(<code>)"}) > do |f| > = f.error_messages > %table > - #... regular form fields with some more indentation ... > = f.submit ''Send It'' > > -# I thought this might work, but onsubmit event is not > firing. Plus it''s a security bomb if JS is disabled in browser. > = link_to image_tag(''message_send.png''), :action => > ''create'', :method => :post, :id => @message > > -------- > > Would really appreciate your help. > > Thank you, > Michael > > -- > 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. >-- 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.