Rails - do AJAX update using HTML template
Apologies if this is asked before, but I can't find it...
I've got a page with a button bar that I need to update as the state of the page changes. The button bar is rendered with a partial.
The user can update the state with various AJAX actions on the page, and I'm doing various updates to the required elements. Mostly these are simple text strings, but the button bar is a bit more complex.
I'd have thought I should be able to do some variation on:
$开发者_开发百科('.button_bar').html( '<%= render :partial => 'buttons.html.erb' %>' );
But I'd need to somehow escape the render output for use in a string. While searching I came across render_to_string, but that just gives undefined method in my application.
I am not sure if I understand right, but
$('.button_bar').html( "<%= escape_javascript(render "buttons") %>" );
精彩评论