# Chained collection\_selects RJS

**URL:** <https://www.ruby-forum.com/t/chained-collection-selects-rjs/124700>\
**Category:** Rails\
**Created:** [January 1, 2008, 8:51am UTC](https://www.ruby-forum.com/t/chained-collection-selects-rjs/124700 "2008-01-01T08:51:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jorge\_Mario\_GSMazo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71c47a/32.png) [@Jorge\_Mario\_GSMazo](https://www.ruby-forum.com/u/Jorge_Mario_GSMazo)\
**Post date:** [January 1, 2008, 8:51am UTC](https://www.ruby-forum.com/t/chained-collection-selects-rjs/124700/1 "2008-01-01T08:51:05Z")

</div>

Hi there I´m trying to get working a bunch of chained collection selects

so it is like this  
from 2 collection selects I replace 2 divs (just text) and generate 2  
more collections selects depeneding on the results from the first 2,  
but then I need to generate to more collection selects, but it fails,  
since when the page is loaded the @collection to generete the  
collection\_select is not net created (it comes from the past 2)  
collection selects, I´m kind of lost of how to solve this problem.  
does anyone have a tip that could I borrow

I´m using rjs to update multiple divs and I´ve tried  
render :update do |page|  
page.replace\_html ‘apDiv5’, @nfc[0].name  
page.replace\_html ‘apDiv9’, @nfc[1].name  
page.replace ‘apDiv11’, :partial =\> ‘ter’, :collection =\> @nfc  
end

but apDiv11 does not work (i have tried replace and replace\_html)

the \_ter.html.erb has  
\<%= f.collection\_select :key\_word … %\>

also I have tried  
page.replace\_html ‘apDiv10’,  
’ 1  
4  
’  
and it works but there has to be a better solution, and it doesnt  
solve me the problem of the later collection not existing when the  
page is loaded

thanks in advance
