Sunday, December 02, 2007

Passing multiple parameters in observe_field

Sometimes you just want to pass multiple parameters on your ajax observe_field web request for processing. If you Google around, you will find out there are multiple ways of doing it.

And here is yet another way:

    observe_field :target_dom_id,
:url => some_named_route_url,
:method => :get,
:with => "Form.serializeElements($('text_field_one', 'text_field_two', ...))"

where 'text_field_one' and 'text_field_two' are html form element ids.

I like this because if my text fields are rendered through form_for or fields_for (e.g. form_for :product), and my action does not want to explicitly specify what the posted parameters are upon processing (e.g. Product.create params[:product]), then by using Form.serializeElements I can hide all the params inside the key params[:product] still.


Anonymous said...

Really superb post.

its helped me....


Fabrice said...

simple and really helpful

Terry S said...

Fabulous! Thank you

Anonymous said...

Great post, helped a lot. Keep going!

evs2td4n07 said...

You can click on the Curaçao seal on the website's footer to verify its validity. Besides having an excellent video slot choice, Super Slots additionally provides nice bonuses, with a welcome bonus of as much as} $6,000. Offers like free spins, match bonuses, and cashback promotions are additionally out there. Super Slots is another high playing website for a full-blown slots experience. Its mother or father company has been round since 1991, and we recommend the platform for its first rate slot choice. Newbies can declare up to as} 메리트카지노 $3,000 on their first three deposits and up to as} $3,750 in the event that they} deposit through crypto.