Collection_select with params :onchange

hello list

this my code

<%= collection_select (“fuentes”, “id”, @fuente, :id, :nombre,
{:prompt => ‘Seleccione mercado’},
:onchange=> {"$(‘btn4’).visualEffect(‘Appear’)"})%>

<%= submit_tag "Crear url" %>

params onchage does´t work!!! why???

thanks everybody

Maite P. wrote:

hello list

this my code

<%= collection_select (“fuentes”, “id”, @fuente, :id, :nombre,
{:prompt => ‘Seleccione mercado’},
:onchange=> {"$(‘btn4’).visualEffect(‘Appear’)"})%>

<%= submit_tag "Crear url" %>

params onchage does´t work!!! why???

thanks everybody

Try putting the :onchange portion in { }. I have a similar drop down
that once you make a selection a remote_function call is activated and
that’s when all the magic happens. I had the same problem as you when I
was trying to get it to work and that is the solution that I found. Here
is what my code looks like:

<%= collection_select(“user”, “contact_country” ,
Countrycode.find( :all, :order => ‘id’ ),
:id, :country, {:include_blank => true, :selected => xxxxx},
{:onchange => remote_function( :update => ‘contact_country’, :url =>
{ :action => ‘set_contact_country’, :id => @user.id}, :with =>
“‘select=’ +
escape(value)” )} )%>

Hope this helps,

-S

thanks, now it is work !!! :slight_smile:

On 11 Aug 2008, at 19:14, Maite P. wrote:

<%= submit_tag "Crear url" %>

params onchage does´t work!!! why???

because there’s no such thing as a javascript visualEffect method.
There is a rails helper visual_effect, that will spit out the
corresponding javascript.
Either use that, or just write the javascript yourself:

$(‘btn4’).appear()
or

new Effect.Appear(‘btn4’)

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