[Rails] Rendering an action (with layout) into a Javascript template
Hi everyone
I have an action:
def index
@settings = Setting.all(:order => 'name')
respond_to do |format|
format.html
format.js
end
end
and corresponding views:
index.html.erb:
<h1>Settings</h1>
...
index.js.erb
$("<%= escape_javascript(render XXX) %>").bigDialog();
So what's happening is that for HTML requests the HTML template will
be rendered (inside application.html.erb) and for Javascript requests
I want the HTML template to be rendered as a string into the
Javascript snippet so that jQuery can throw out a dialog. The catch is
that dialogs have a separate layout file, dialog.html.erb.
Is there a way to render a template with a layout into my Javascript
snippet where I've typed "render XXX"? I've looked at render_to_string
but that breaks MVC by taking view material into the controller.
Ideally, I'd like something like render(:action =>
'index.html.erb', :layout => 'dialog') (note index.html.erb to
distinguish it from index.js.erb) and have this rendered inline.
Ideas?
Thanks!
Tristan
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home