Skip to content

Instantly share code, notes, and snippets.

@fdv
Created January 5, 2014 09:34
Show Gist options
  • Save fdv/8266262 to your computer and use it in GitHub Desktop.
Save fdv/8266262 to your computer and use it in GitHub Desktop.
# dans autosave
respond_to do |format|
format.js
end
# autosave.js.erb
$('#autosave').replaceWith("<%= hidden_field_tag('article[id]', @article.id) %>")
$('#destroy_link').replaceWith('<%= link_to_destroy_draft(@article) %>')
$('#publish').replaceWith("<%= text_field_tag('article', 'published_at', {:class => 'span7 datepicker'}) %>")
<%= gflash :success => _("Article was successfully saved") %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment