You are here: Forums Ask a Rails expert Rendering a template with rend...
Posted in Forums : Ask a Rails expert
Authority 37
Posting Rating 100
Sign in to rate this post
|
Hi there, I’m currently working on a page that relies heavily on AJAX. Apart from the main area, most content opens up in one popup window (a div), i.e. the same div is used for all contents.
respond_to do |format|
format.js do
render :update do |page|
page[:popup].replace_html :template => "customers/index.html.erb"
end
end
end
The reason I don’t want to put this in a partial is that I use the same templates as a fallback for users that have javascript disabled. Unfortunately, this doesn’t seem to work because Rails doesn’t recognize the :template option with :update. As soon as I replace it with a :partial option, everything works smoothly. Before trying this approach, I had link_to_remote with an :update option, but I don’t like this for various reasons – mostly, because it bloats my controllers with conditionals. Does anyone have a suggestion what I should do? I’m open to code changes, too, if you think that helps. Cheers, |
Authority 37
Posting Rating 84
Sign in to rate this post
|
I believe one way is to put that code into a partial, then create the template that uses the partial _index.html.erb <div>my partial code here</div> index.html.erb <%= render :partial => 'index' %> |
Authority 37
Posting Rating 100
Sign in to rate this post
|
Yes, Jeff, this is exactly how I worked around this problem. It looks kind of sucky, but well, it works … Thanks anyway. |
Ask a Rails expert : First post, requesting sage perspective
Ask a Rails expert : How to use mephisto
Ask a Rails expert : How to use mephisto
Ask a Rails expert : will_paginate customization problem
Ask a Rails expert : BackgroundRB still wants 'development' environment...?
Ask a Rails expert : activescaffold, sql exception
Ask a Rails expert : Passing non-english chars in query string
Ask a Rails expert : Rails and 2D barcodes
Ask a Rails expert : apache giving proxy error
Ask a Rails expert : Custom Responses w/ 'extra' information...?