<%= form_for @quote, remote: true, html: { id: "quote-#{@quote.id}" } do |f| %>
<div>
  <%= f.text_area :raw_quote, rows: 10, cols: 70 %>
</div>
<div>
  <%= f.label :description, 'Optional description:' %>
  <%= f.text_area :description, rows: 2, cols: 70 %>
</div>
<div>
  <%= f.submit 'Save' %>
  <%= button_to_function 'Cancel', "$('#quote-#{@quote.id}').replaceWith('#{j render @quote}');" %>
</div>
<% end %>

<%= form_for @quote, remote: true, html: { id: "quote-#{@quote.id}" } do |f| %>
<div>
  <%= f.text_area :raw_quote, rows: 10, cols: 70 %>
</div>
<div>
  <%= f.label :description, 'Optional description:' %>
  <%= f.text_area :description, rows: 2, cols: 70 %>
</div>
<div>
  <%= f.submit 'Save' %>
  <% if @quote.id %>
  <%= button_to_function 'Cancel', "$('#quote-#{@quote.id}').replaceWith('#{j render @quote}');" %>
  <% else %>
  <%= button_to_function 'Cancel', "$('#quote-#{@quote.id}').remove();" %>
  <% end %>
</div>
<% end %>

Fix cancel button for new unsaved forms
Fix cancel button for new unsaved forms
