Thursday, May 29, 2008

Rails RJS examples and official doc

With rjs, you can call the ajax helper without specifying the html elements. Moreover, you can do whatever you want after the action(update several divs, etc.).

render :update do |page|
page.replace_html 'div1', "HAHA"
page.replace_html 'div2', :partial => 'person', :object => @person

OR, you can create a rjs template:show.js.rjs, and put the rjs code there.

In the controller, you'll then have:
def show
...
#no render at all
end

Rails will pick the right template automatically.

Official rjs docs

1 comment:

Anonymous said...

Thanks...it was useful