Tuesday, November 9, 2010

[Rails] Re: help getting started with javascript generated forms

On Nov 9, 11:11 pm, Fearless Fool <li...@ruby-forum.com> wrote:
> How does one generate a form within a view using javascript?
>
> Specifically, assume views/premise/new.html.erb looks like this:
>
> <%= form_for(Premise.new) do |f| %>
>   <%= f.hidden_field :full_address, :value => $FULL_ADDRESS %>
>   <%= f.hidden_field :geocoding, :value => $GEOCODING %>
>   <%= f.submit :value => "use this address" %>
>   <%= f.label :formatted_address, $FULL_ADDRESS %>
> <% end %>
>
> ... but with the twist that this form must be generated on the client
> side by javascript.  (In this case, $GEOCODING and $FORMATTED_ADDRESS
> are placeholders for values generated by the Google geocoding service,
> which requires client-side javascript.)
>
> One approach would be to look at the HTML generated by the above .erb
> code and write javascript functions that emit HTML directly. But this
> approach reeks -- there must be a better way!
>

Another would be to have the form created server side (ie normally),
but fill in the form values client side once they become known (and if
you care you can have the form hidden initially and show it only once
the geocoding data is available)

Fred
> Assuming there is a better way, where do I look for documentation and
> examples?
>
> --
> Posted viahttp://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate