Chris Roos wrote:> Hi,
>
> I''ve been trying to crack this all evening and have finally given
in and
> decided to ask for help.
>
I''ve just got this to work but I''m not convinced it''s
the best way to do
things.
> I created a page that had two (html) forms. The first form was a
> ''lookup'' form whereby the user types in a search
parameter and hits
> ''search'' in order to return a result which is then used
as part of the
> second form. This works fine as the entire page reloads and so I can
> populate a hidden field on the second form with the value of the search
> result.
>
To resolve the problem, I have placed the first ''lookup'' form
in a
partial, within a div. The action for this form is a search method.
The :update parameter to the form_remote_tag method is set as the id of
the div. The search method performs a Sql lookup based on the value in
the search field of the ''lookup'' form. Once complete, the
search method
calls render_partial to basically ''refresh'' the top
''lookup'' form. This
form now has access to the object returned from the search method. A
final :complete callback on form_remote_tag is set to update the value
of a hidden field in the second form with the results of the data now
populated in the first form, using $(''hidden_field1'').value =
$(''hidden_field2'').value syntax.
I''m not sure I''ve written that explanation very clearly, in
fact, I''m
pretty certain I haven''t. Rest assured that it is currently working
though.
> My first question would be whether or not this is even the right way to
> go about what I am attempting to achieve.
>
This question still stands. How would other people attack this same
problem? I''m very interested in any input people have.
> Thanks in advance,
>
> Chris
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>