I am appending code to a div block from a partial using unobtrusive javascript. Inside my views there are two folders called videos and posts. In the the video folder is a show.html.erb file. In this show.html.erb file there's a form to allow a user to create a post. The form attribute remote is set to true and I want the post that gets submitted by the form to be loaded onto the page (the same show.html.erb page) without having to refresh (AJAX functionality). When the form is submitted it is sent to the create method of the posts controller. In this method there's a
format.js
that calls views > posts > create.js.erb.
The code I have written for this file so far is:
$('#comments').append('<%=escape_javascript(render(:partial => 'posts'))%>');
comments is the div id for a block in the show.html.erb file. The partial 'posts' is inside the posts folder (views > posts > _posts). Right now this is not working properly and I believe its because the create.js.erb file is in a separate folder from the file whose div id its trying to reference. How do I get the javascript code from the posts folder to reference the div block inside the video show file? Thanks.