0
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. I put myself in _content_recommendation.html.erb
:
<h3>Ultimos itens visitados:</h3><p>teste</p>
(no spaces) it works...
Awkward, consider marking your answer as correct by clicking left below the score. Thank you!
– utluiz