views:

53

answers:

1

Hello,

Again,quite new to Ruby on Rails and Ajax, both. I heard it is supposed to be quite easy to add Ajax stuff into the web sites, and since my forms are somewhat done, I thought I would give it a try.

But there are some problems, unfortunately, that I could not really find the fitting documentation. I tried with the only method I found suitable observe_field, and it creates some JavaScript code which does nothing.

So basically, I wanted to ask for a general way how to do that. This is the select I want to observe:

<div class="field"><%= collection_select :species_id, 
    Species.all, :id, :name %></div>
<%# Ruby-Ajax goes here? %>
<div id="species-preview"><%= render :partial => 'species/species' %></div>

So yes, what I want to do is: Whenever the user selects another species, the second should show a little preview about it.

I read the docs and searched here for examples, but it all left me kind of confused. So thanks for your time.

A: 

See the simple and much explained examples of Ajax. very close to your requirement.

I hope these will not confuse you

http://www.plus2net.com/php_tutorial/php_drop_down_list.php

http://www.w3schools.com/php/php_ajax_livesearch.asp?

If interested try jquery instead of javascript

http://api.jquery.com/val/

zod