Struggling to incorporate js.erb script into my view for a polling-based chat feature. What seemed straightforward at first has turned into a complex task.
Snippet of the js.erb script:
$( document ).ready(function() {
$(function() {
setTimeout(updateMessages, 1000);
});
function updateMessages () {
var game_id = $("#game_chat").attr("data-id");
$("#messages").html("<%=escape_javascript(render(:partial => 'messages')) %> ");
setTimeout(updateMessages, 1000);
}
});
The corresponding partial code is simple:
<%= render @messages %>
Encountering difficulties in linking .js.erb code within the view. Attempted using this approach without success:
<%= javascript_include_tag "games/messages.js.erb" %>