Jesper Rønn-Jensen
2006-Apr-17 20:37 UTC
[Rails] Autocompleter to read value from hidden field
I have an autocomplete field with road names (looking up in a database with approx. 100,000 road names). To limit the number of roads, i want an extra input field where to put postal code. I''m currently using <%= text_field_with_auto_complete %> for the field. What is the best way in Rails to intercept the Ajax call and send the value of the postal_code field? (I guess I could do it by hand, but I think that there is a smarter way of doing this). Thanks! -- -- Jesper R?nn-Jensen +45 23 73 62 20 (Mobile) http://justaddwater.dk/ (weblog) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060417/fc98b094/attachment.html
I believe you could play with the ":with" parameter of observe_field to send value of both fields with AJAX call instead of value of only the observed field. For that, I would think you should put some javascript function that collects the value and concatenates it in some form to the value of observed field. On 4/18/06, Jesper R?nn-Jensen <jesperrr@gmail.com> wrote:> > I have an autocomplete field with road names (looking up in a database > with approx. 100,000 road names). > To limit the number of roads, i want an extra input field where to put > postal code. > > I''m currently using <%= text_field_with_auto_complete %> for the field. > > What is the best way in Rails to intercept the Ajax call and send the > value of the postal_code field? > > (I guess I could do it by hand, but I think that there is a smarter way of > doing this). > > Thanks! > > -- > > -- > Jesper R?nn-Jensen > +45 23 73 62 20 (Mobile) > http://justaddwater.dk/ (weblog) > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060418/7f9bd999/attachment.html