Rendering a partial for AJAX response

Hi all!
I want to have an action to process an AJAX request. Naturally, it is
good to render a partial as the response. The problem is, Rails
supposes all actions to end with render :action otherwise it
automatically renders the default action. How to cancel such behaviour
and make it happy with just rendering the partial and finishing?

Damian T. wrote:

I want to have an action to process an AJAX request. Naturally, it is
good to render a partial as the response. The problem is, Rails
supposes all actions to end with render :action otherwise it
automatically renders the default action. How to cancel such behaviour
and make it happy with just rendering the partial and finishing?

This requires the view to call a wrapper that calls Ajax.Request, not
Ajax.Response, but that’s just my preference:

render :update => do |page|
page.replace_html ‘my_div’, :partial => ‘my_partial’
end

Ajax! The Guilty Pleasure of Rails!!


Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!

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