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

hyperrjas picture hyperrjas · May 7, 2012 · Viewed 8.2k times · Source

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.

Answer

hyperrjas picture hyperrjas · May 7, 2012

The fix:

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

Thank you to Carlos Antonio da Silva in.

http://groups.google.com/group/plataformatec-simpleform/browse_thread/thread/6f2cdd83e2dbf51c