Hi,
I have a form with two drop down menus.
Depending on what the user selects in the first, the second should be
populated accordingly.
Here is the code I am using to do this.
View (test.html.erb):
<% form_for :applicant, :url=> {:action => “index”} do |f| %>
<%= f.label :topic_1 %>
<%= f.select :topic_1, [“a”, “b”, “c”, “d”, “e”, “f”], :include_blank =>
true %>
<%= observe_field “applicant_topic_1”, :update => “applicant_member_1”,
:with => “topic_1”, :url => { :controller => “form”, :action =>
“get_members_1” } %>
<%= f.label :member_1 %>
<%= f.select :member_1, [“Please select topic 1 first”] %>
Controller:
def get_members_1
@members_1 = Member.find_all_by_topic params[:topic_1]
end
View (get_members_1.html.erb):This is no. 1 (I have shortened this for sake of simplicity. Normally a lookup of all members would take place here)
As you can see, when the user enters something in ‘topic_1’ the
observe_field helper calls the method ‘get_members_1’ in the controller,
and updates the field ‘member_1’ dynamically.
Here is this example in action:
My problem is that this works fine in FF, IE, Chrome and Opera, but it
doesn’t work at all in Konqueror.
I have Googled the problem and come up empty handed.
This is the java script that the helper generates:<![CDATA[ new Form.Element.EventObserver('applicant_topic_1', function(element, value) {new Ajax.Updater('applicant_member_1', '/test/get_members_1', {asynchronous:true, evalScripts:true, parameters:'topic_1=' + encodeURIComponent(value) + '&authenticity_token=' + encodeURIComponent('EWNBpyzHQtObzxZbuXqg2s0tUHw8JWJhaeKZiyvWO9E=')})}) //]]> <p>Can anybody point me in the right direction to sort this out?<br> I am relatively ok at ruby / rails, but a beginner regarding java script<br> / ajax.</p> <p>I also had a look on the rails doc page regarding observe_field, but I<br> cannot see what I am doing wrong.</p> <p>I would be grateful for any help.</p>