I’m trying to write a coffeescript to prepend a new element into a content_tag_for block. And if possible using a partial for code simplicity sake.
<ul id="documents">
<% @documents.each do |document| %>
<%= content_tag_for :li, document do %>
<%= document.title %>
<%= document.position %>
<%= link_to 'Delete', document, method: :delete, remote: true %>
<% end %>
<% end %>
</ul>
And my create.js.coffee attempt. But using a partial caused issues because when I run this, the element is added without a
$('<%= escape_javascript(render(:partial => @document))%>')
.prependTo('#documents')
.hide()
.fadeIn()
$('#new_document')[0].reset()
Solved.
my updated create.js.coffee