I have an ajax that fires when the page loads:
/assets/javascript/itens.js
:
if ($('#content-recommendation').length) {
xhr = $.ajax({
url:'/get_recommendations/' + gon.item_id + '.js',
type:"get"
});
}
views/items/show
:
<div id="content-recommendation" class="col-md-3">
<p>hey!</p>
</div>
itens_controller#get_recommendation
:
def get_recommendations
respond_to do |format|
format.js
end
end
itens/get_recommendations.js.erb
:
$("#content-recommendation").html("<%= render 'content_recommendation'%>")
_content_recommendation.html.erb
:
<h3>Ultimos itens visitados:</h3>
<p>teste</p>
This is by far the strangest problem I found in RoR. If I put in _content_recommendation.html.erb
:
<h3>Ultimos itens visitados:</h3><p>teste</p>
(without spaces) it works ...