add :onchange => "readURL(this)" to input file in simple_form

1,377 views
Skip to first unread message

hyperrjas

unread,
May 7, 2012, 7:25:46 AM5/7/12
to SimpleForm
Hi guys, I have a problem with this:

I want add :onchange => "readURL(this)" to my:

<%= f.input :image, :as => :file, :onchange => "readURL(this)" %>

I have tried with:

<%= f.input :image, :as => :file, :html => {:onchange =>
"readURL(this)"} %>

but I can not see the onchange="readURL(this)" in html code.

How can I fix this problem?

Thank you again :D.

Carlos Antonio da Silva

unread,
May 7, 2012, 7:39:09 AM5/7/12
to plataformate...@googlegroups.com
To add html attributes to the input, you have to use :input_html => {}.. Same for label or errors: :label_html => {}.

-- 
At.
Carlos Antonio

hyperrjas

unread,
May 7, 2012, 7:42:58 AM5/7/12
to SimpleForm
Thank you very much again Antonio :D works great!

Thank you very much again!

On May 7, 4:39 am, Carlos Antonio da Silva

Jonathan Telfer

unread,
May 8, 2012, 4:40:51 AM5/8/12
to plataformate...@googlegroups.com


Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages