Ajax on Rails

Hey Mick, please provide the relevant view code.



Also sometimes is better to use rjs file instead of rendering rhtml,

Like if you have loading indicator and you need update two or moder
DOM's elements,

in form_rhtml:
<div style="display: none" id="loading">Loading…</div>
<div id="total_comments">2</div>
<div id="comments">comments here</div>
<%= form_remote_tag :url => {:controller => 'article', :action =>
'addComment', :id => article.id },
          :loading => "Element.show('loading'),
                       :complete => "Element.hide('loading') } %>
… form goes here with end form tag,…

Now in action you are saving posted comments, ....
in addComment.rjs:
page.replace_html 'total_comments', @comments.size
page.replace_html 'comments', :partial => "comments"

Thats all,
(mayb i misspelled something, but that's a way)