How HTML_Option works?


#1

Hi all,

all the form helpers can take a serie for options but I cant find any
documentation about them. Any one can point me toward one?

Or at least tell me how I can for example add a function that would be
call with the onblur event from a input box?

Thanks!


#2

On Monday, May 22, 2006, at 3:56 PM, Alain Pilon wrote:


Posted via http://www.ruby-forum.com/.


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails

HTML options just get added to the HTML output as an attribute…

so if you have an HTML option hash like this {‘onBlur’=>‘function()’} it
will just add ‘onBlur=function()’ to the output HTML in the correct
spot.

_Kevin


#3

On Monday, May 22, 2006, at 3:56 PM, Alain Pilon wrote:


Posted via http://www.ruby-forum.com/.


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails

Like this for model “post”, field “title”:

text_field(“post”, “title”, {“size” => 20, “maxlength” => 40})

yields this HTML:

You can add your onblur => “whatever” as an additional option.


#4

Ok, it worked but I have another problem now…

I am using this form_remote_tag to manage my form:

form_remote_tag( :url => {:action => “update_variation”},
:loading =>“Element.show('search-indicator_” +
h(@generic_variation.id.to_s) + “’)”,
:complete => “Element.hide('search-indicator_”+
h(@generic_variation.id.to_s) + “’)”,
:html => {:name => “form_for_” + @generic_variation.id.to_s})
-%>

This form includes a few input fields and I want the onblur event of
these fields to send the form.

Right now, its not working because then I use this:

<%= text_field(“generic_variation”, “name_fr”, :onblur =>
“document.form_for_” + @generic_variation.id.to_s + “.submit()”) -%>

my browser goes to …/update_variation insted of just running the ajax
code.

How can I solve it?


#5

I found a way to fix this…

My input box call document.name_of_form.onsubmit() insted of .submit().

It works but is there a better way?


#6

Oh thanks!

Much simpler than I expected!