render partial and text in one action

Hey all,

how can i render :partial and render :text in one action?

I need to update the partial and update an div field with some html
data.

Thanks for your help :slight_smile:

How about you use render :update instead?

How about you use render :update instead?

But how to call the partials?

render :update |page|

page.xxxx partials...?

end

Stephan Meier wrote:

How about you use render :update instead?

But how to call the partials?

render :update |page|

page.xxxx partials...?

end

Actually... what you are trying to do doesn't seem to be possible this
way. You can only call render ONCE IN A CONTROLLER per request. To clear
things up a little, what exaclty is your situation?

a) You have a page rendered in the browser and you want to replace a
part of it with a partial and some other part with a text via ajax?

Then you can use:

render :update do |page|
  page[:name_of_part].replace_html :partial => :name_of_partial
  page[:name_of_other_part].replace_html "New Text"
end

render :update (in this case) sends a javascript back to your browser,
which updates the elements given by page[:element_id].

b) You have a normal request and you want to render multiple things from
your controller?

Not possbile this way. You can call render as many time as you want in a
view, but only once per action in a controller. So you have to redesign
this part of your app.

Hope this helps.

Mike

I'm not 100% sure what you're doing, but look at render_to_string.