replace_html and page.select behaviour

Hi,

I want to update a div element selected using its class. This is the code I tried in the RJS:

page.replace_html page.select('#account div.content').first, :partial => 'my_html'

and also

page.select('#account div.content').first.replace_html :partial => 'my_html'

Neither work whereas the following do work:

page.select('#account div.content').each do |d| page.replace_html d, :partial => 'boxes/account' end

I miss something, can someone explain me?

Wrong copy/paste: the partial called is the same for all...

Page.select return a collection of object, thus you have to iterate over each element before using page.replace_html

_Aurélien Bottazini_ http://www.mycashgarden.com

To be slightly more precise page.select is a magic proxy object. I went into it in some detail here: Conditional RJS explained - Space Vatican

Fred