Topic: Rendering partial via AJAX call in Rails
I have a multi-part form composed of three partials. The names of my partials are stored in @user.current_step. My form looks like this:
<%= form_for(@user, :html => { :class => "form-horizontal" }, remote: true) do |f| %>
<%= render 'shared/error_messages' %>
<div id="partial">
<%= render @user.current_step, :f => f %>
</div>
<div class="control-group">
<div class="controls">
<%= f.submit "Previous", class: "btn btn-primary", :name => "prev_button" unless @user.first_step? %>
<%= f.submit "Next", class: "btn btn-primary", :name => "next_button" %>
</div>
</div>
<% end %>Now to move between the partials I update @user.current_step within my controller when I click on 'Next' or 'Previous'. To load the partials I try this:
$("#partial").html("<%= escape_javascript(render @user.current_step, f: f) %>");But this isn't working. Also my 'Previous' button doesn't show up. It looks like the code unless @user.first_step? isn't working either. Any ideas?