using image_tag as submit button inside form_for block in haml

442 views
Skip to first unread message

Liberty1776

unread,
Mar 10, 2010, 10:09:56 PM3/10/10
to Haml
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 this by link_to image_tag?
--------
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.
= link_to image_tag('message_send.png'), :action =>
'create', :method => :post, :id => @message

--------

Would really appreciate your help.

Thank you,
Michael

Nathan Weizenbaum

unread,
Mar 10, 2010, 11:41:01 PM3/10/10
to ha...@googlegroups.com
This is more of a Rails question than a Haml question, isn't it? Does it have anything specific to do with Haml?


--
You received this message because you are subscribed to the Google Groups "Haml" group.
To post to this group, send email to ha...@googlegroups.com.
To unsubscribe from this group, send email to haml+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/haml?hl=en.


Liberty1776

unread,
Mar 11, 2010, 1:53:54 AM3/11/10
to Haml
Yes, you're right. It's not haml at all. I just had this fixation on
it.
A partial answer is in
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/6bb898711a197444/4dbb93143ebecbc9?lnk=gst&q=image_tag+submit#4dbb93143ebecbc9

Best Regards,
Michael

On Mar 10, 10:41 pm, Nathan Weizenbaum <nex...@gmail.com> wrote:
> This is more of a Rails question than a Haml question, isn't it? Does it
> have anything specific to do with Haml?
>

> > haml+uns...@googlegroups.com <haml%2Bunsu...@googlegroups.com>.

Liberty1776

unread,
Mar 11, 2010, 2:09:12 AM3/11/10
to Haml
Actually there is a haml question here:
I ended up writing this:
= link_to image_tag('message_send_button.png', |
:alt => 'Send it!', |
:onmouseover =>
"this.src='message_send_button_hoverstate.png'", |
:onmouseout =>
"this.src='message_send_button.png'"), :action => 'create', :id =>
@message

But it doesn't work. I get a message:
invalid filter name ":onmouseout =>
"this.src='message_send_button.png'"), :action => 'create', :id =>
@message".

It seems to complain about the last line no matter which of these
strings above I put in.

How would you suggest to break this statement into multiple lines in
haml?

On Mar 11, 12:53 am, Liberty1776 <mlivsh...@gmail.com> wrote:
> Yes, you're right. It's not haml at all. I just had this fixation on
> it.

> A partial answer is inhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/...

Nathan Weizenbaum

unread,
Mar 11, 2010, 2:30:12 AM3/11/10
to ha...@googlegroups.com
You should really put this in a helper. The reason the multiline isn't working is because you need a pipe on the last line as well, but see http://haml-lang.com/docs/yardoc/file.FAQ.html#q-multiline.

To unsubscribe from this group, send email to haml+uns...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages