Pablo, estoy usando algo similar en un proyecto:

*_form.rhtml*

<p><label for="affiliate_state">Estado</label><br/>
<%=
 @states = [["Seleccione ...", ""]] + State.find(:all, :order =>
"name").map {|s| [s.name, s.id]}
 select(:affiliate, :state_id, @states, {},
   :onChange => remote_function( :with =>
"'affiliate[state_id]='+escape(value)",
   :complete => evaluate_remote_response,
   :before => "Element.show('spinner')",
   :success => "Element.hide('spinner')",
   :url => { :action => :state_changed },
   :update => "counties-combo"))
-%>

<span id="counties-combo">
 <%= render :partial => "counties", :locals => {:state_id => @
affiliate.state_id} %>
</span>

*_counties.rhtml*

<p><label for="affiliate_county">Municipio</label><br/>
<%=
 @counties = [["Seleccione un Municipio", ""]] +
County.find_by_state_id(state_id).map
{|c| [c.name, c.id]}
 select(:affiliate, :county_id, @counties)
%>
<%= image_tag("spinner.gif",
     :border=> 0,
     :id => "spinner",
     :style=>"display: none;" ) %>

*affiliates_controller.rb*

def state_changed
 render :partial => "counties", :locals => {:state_id =>
params[:affiliate][:state_id].to_i}
end

Espero te sirva.


Saludos

Ariel

On 3/16/07, Pablo Rodriguez <[EMAIL PROTECTED]> wrote:

Yo quiero que en el evento onChange del select ejecute una funcion
ajax que me actualiza otra parte de la pantalla.

Quiero algo parecido a este ejemplo...pero que funcione con un select
<table>
  <% for email in @emails %>
     <tr ondblclick="<%= remote_function(:update => 'email_body',
                               :url => {:action => 'get_email',
                               :id => email})">
    <td><%= email.id %></td><td><%= email.body %></td>
</tr>
<% end %>
</table>
<div id="email_body" />

Como le agrego la llamada de remote_function a
  <%= collection_select(:category, :id, @all_categories, :id, :long_name)
%>

Muchas gracias

Pablo R
On 3/16/07, nelson fernandez <[EMAIL PROTECTED]> wrote:
> para eso no haria falta llegar a ajax..... el SELECT tiene un evento
> javascript llamando onChange.....
>
> --
> :: nelson ::
> artesano de software
> http://netflux.com.ar
>
>
> On 3/16/07, Pablo Rodriguez <[EMAIL PROTECTED]> wrote:
> > Hola
> > Estoy siguiendo un ejemplo de un libro de RoR
> >
> > <label for="category_id">Filter "Unused Photos" on this
Category</label><br/>
> >   <%= collection_select(:category, :id, @all_categories, :id,
:long_name) %>
> >
> >   <%= observe_field(:category_id,
> >                :frequency => 0.5,
> >                :update => 'slideshow-photos',
> >                :url => { :action => 'change_filter'},
> >                :with => 'category_id' ) %>
> >     </p>
> >
> > Tengo una lista, y defino un observer_field sobre esa lista, para que
> > cada medio segundo valide si cambio ese valor.
> > Lo que quiero es que cada vez que cambia el valor de la lista se
> > dispare el evento , no que valide cada 0.5 seg.
> > Como hago para agregar ese fire event al "collection_select",
> > @all_categories es una lista de objetos Categories que tiene la
> > propiedad :id y :long_name.
> >
> > Se entiende ?
> >
> > Saludos
> > Pablo Rodriguez
> > --
> > Pablo Rodrigueez
> > _______________________________________________
> > ruby mailing list
> > [email protected]
> >
http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar
> >
> _______________________________________________
> ruby mailing list
> [email protected]
> http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar
>


--
Pablo Rodrigueez
_______________________________________________
ruby mailing list
[email protected]
http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar




--
"The whole problem with the world is that fools and fanatics are always so
certain of themselves, but wiser people so full of doubts"

           Bertrand Russell
_______________________________________________
ruby mailing list
[email protected]
http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar

Responder a