How to update a collection_select from another

I have two collection_select in my list.rhtml:
<%= collection_select (:region, :id, @regionall, :id,
:title,html_options={:onChange => “new
Ajax.Updater(‘related_provinces’,’/categories/related_provinces/” +
“?id=’+this[this.selectedIndex].value,
{asynchronous:true, evalScripts:true});”}) %>

<%= render :partial => “related_provinces” %>

This is my partial:
_related_provinces.rhtml:
<%= collection_select(:region, :id, @provinces, :id, :title) %>

category_controller.rb:
def list
@regionall = Region.find(:all, :conditions => [ “parent_id = ?”,
‘1’],:order=>“id”)
@provinces = Region.find(:all, :conditions => [ “parent_id = ?”,
@region.parent.id],:order=>“id”)
end

The problem is that it doesn’t even display the onChange javascript
code:

bla1

bla2 bla3
blop1 blop2 blop3

Could you please tell me first why my JS code isn’t display and second
if the ajax update JS code is correct? :slight_smile:

Thanx in adance

Pat

Try reading this thread;

http://www.nabble.com/forum/ViewPost.jtp?post=4302805&framed=y

I was trying to do a similar thing, and the guys were very helpful.

Good Luck.

Patrick A. wrote:

_related_provinces.rhtml:

Could you please tell me first why my JS code isn’t display and second


View this message in context:
http://www.nabble.com/how-to-update-a-collection_select-from-another-tf2117540.html#a5839937
Sent from the RubyOnRails Users forum at Nabble.com.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs