Help with selection list

Hi,

I want to make a selection list, which I call a dropdown, which, when
a user makes his or her selection, will do an ajax call, and update a
partial. Without hitting a button – the ajax request will fire off
upon the selection.

I’d appreciate a hint – can’t figure out where to start.

Charlie

Charlie,

The Agile Book is always a good place to start looking for things
Rails. In your case, page 523-526 in the 2nd Edition has some good
stuff that can get you started on what you want.

Regards,
Rajesh

Is a form observer the way to go with this? I was thinking of just
doing an onchange, so that when any element is selected, it fires off
an ajax request.

Either way would work. I prefer to write less javascript and let the
observer deal w/ the ajax request, but they will both do basically the
same thing one is a little more rails, the other a little more
javascript.

charlie caroff wrote:

stuff that can get you started on what you want.

a user makes his or her selection, will do an ajax call, and update a


Sincerely,

William P.

http://www.billpratt.net
[email protected]

I use observers for this all the time doing exactly what you want. I use
it in my pagination footer. I give the user a list of available pages,
and if a new page is chosen, the observer fires off an ajax request
which then uses rjs to update the page results.

K. Rajesh wrote:


Sincerely,

William P.

http://www.billpratt.net
[email protected]

By way of an example:

The default for observe field is on change so the call to remote
occurs whenever a selection is made:

   <%= select 'order', 'ship_method',
     ['1st Class Standard', '1st Class Recorded','Next Day

Courier’, ‘Special Delivery’ ]%>

<%= observe_field :order_ship_method,
:url=>url_for(:action=>:edit_batch_field,
:controller=>‘order’, :id=>@order.id),
:with=>“ship_method”

              %>

hth
Tonypm

Very good. Thanks to all. This is one of those things where I didn’t
know what to look for in the first place. Got it working now.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs