I have an action 'index', that when called via ajax, renders index.js which renders a partial:
$("#content").html("<%= escape_javascript(render :partial => 'index') %>");
How do I make the same thing happen in the html response? I tried:
format.html { render "i开发者_JS百科ndex.js" }
And although I don't get any errors, the js code doesn't seem to run, because the partial doesn't render.
Have you tried wrapping the script inside <script>
tag?
Your index.html.erb
would look like this:
<script type="text/javascript">
$("#content").html("<%= escape_javascript(render :partial => 'index') %>");
</script>
The default render is a shortcut for render :action => :action_name
. To specify a filesystem path use render :file => "index.js"
精彩评论