collection_select with params :onchange

hello list

this my code

  <%= collection_select ("fuentes", "id", @fuente, :id, :nombre, {:prompt => 'Seleccione mercado'},   :onchange=> {"$('btn4').visualEffect('Appear')"})%></p>   </td>   </tr>   <tr>   <td><div id="btn4" style= display:none>     <%= submit_tag "Crear url" %>   </div></td>

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

thanks everybody

Maite Piedra wrote:

hello list

this my code

  <%= collection_select ("fuentes", "id", @fuente, :id, :nombre, {:prompt => 'Seleccione mercado'},   :onchange=> {"$('btn4').visualEffect('Appear')"})%></p>   </td>   </tr>   <tr>   <td><div id="btn4" style= display:none>     <%= submit_tag "Crear url" %>   </div></td>

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

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')