Forum: Ruby on Rails how HTML_Option works?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Alain P. (Guest)
on 2006-05-22 17:56
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!
Kevin O. (Guest)
on 2006-05-22 18:31
(Received via mailing list)
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
Richard W. (Guest)
on 2006-05-22 18:44
(Received via mailing list)
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:

  <input type="text" id="post_title" name="post[title]" size="20"
maxlength="40" value="#{@post.title}" />

You can add your onblur => "whatever" as an additional option.
Alain P. (Guest)
on 2006-05-22 18:46
Oh thanks!

Much simpler than I expected!
Alain P. (Guest)
on 2006-05-22 19:37
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?
Alain P. (Guest)
on 2006-05-22 19:43
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?
This topic is locked and can not be replied to.