Wednesday, May 19, 2010

[Rails] observe_field not working on dependeng collection_select

Setup:

I have 3 drop downs generated by collection_select, where in the next
drop down's option values are dependent on which option value was
selected in the previous drop down. This is done using observe_field.

e.g.
country => state => city

Here's the code:
%div
.label
Grading Scheme Select - Tier 1
= collection_select (:grading_scheme, :id, GradingScheme.all, :id,
:name)
= observe_field('grading_scheme_id', :update => 'parent_div',
:frequency => 0.5, :url => {:controller => 'grading_schemes', :action =>
'filter_parents'}, :with => 'grading_scheme_id')
%div
.label
Tier 2
#parent_div
= collection_select (:grade_layer, :id, @parents, :id, :name)
= observe_field('grade_layer_id', :update => 'child_div', :frequency
=> 0.5, :url => {:controller => 'grading_schemes', :action =>
'filter_children'}, :with => 'id')
%div
.label
Tier 3
#child_div
= collection_select (:grade_layer, :id, @children, :id, :name)

Initially the observe_field would work on updating child_div (Tier
3)whenever I select a different item in Tier 2. If I select a grading
scheme in Tier 1, Tier 2 will update its list. However if i select a new
item in that updated list in Tier 2, Tier 3 will not update.

I've checked my local server, and during those occassions that Tier 3
doesn't update i find that ajax isn't producing any calls. I hope
someone can help me out on this.
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate