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! -- Posted via http://www.ruby-forum.com/.
On Monday, May 22, 2006, at 3:56 PM, Alain Pilon wrote:>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! > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsHTML 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 -- Posted with http://DevLists.com. Sign up and save your mailbox.
On Monday, May 22, 2006, at 3:56 PM, Alain Pilon wrote:>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! > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsLike 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. -- Posted with http://DevLists.com. Sign up and save your mailbox.
Oh thanks! Much simpler than I expected! -- Posted via http://www.ruby-forum.com/.
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? -- Posted via http://www.ruby-forum.com/.
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? -- Posted via http://www.ruby-forum.com/.
Not sure about how to get the exact scenario below to work, but an alternative is to use Observers. Observers let you monitor a field and make an ajax call to the handler when the value changes. It even sends the new value to the handler. Described nicely in the ajax on rails article at http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html?page=2 Hope this will help Bharat>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?