1
가 어떻게 아약스 함수에서 일부를 호출 할 수 있습니다 AJAX URL 레일에서 부분, 내 home.html.erb 내부 부분의 내용을 렌더링 할 필요가 여기에 코드 :전화가
<div class="span8">
<h3>Micropost Feed</h3>
<div class="posts">
<%= render 'feed' %>
</div>
</div>
나는 스크립트가 하단에서
, 문제의 코드는 다음 줄에 있습니다
if(nearBottomOfPage()) {
loading=true;
page++;
$.ajax({ // send an ajax-request to load the next page
url: '/feed?page=' + page,
type: 'get',
dataType: 'script',
success: function() { // after successfully completing the ajax-request redraw the sausage-navigation.
$(window).sausage('draw');
loading=false;
}
});
은 "URL"매개 변수가 나는 부분 전화를 쓸 모르는 곳이며,이 부분은 전화 _feed입니다 .html.erb 그리고 그것은 같은 f 안에 있습니다.
def home
if signed_in?
@post = current_user.posts.build
@feed_items = current_user.feed.order(:created_at).page(params[:page])
end
respond_to do |format|
format.js { render :partial => 'feed'}
format.html # index.html.erb
format.xml { render :xml => @feed_items }
end
end
가 어떻게 호출 할 수 아약스 함수의 부분 : 내 컨트롤러 액션에서 마침내, Home.html.erb의 이전 나는이 있나요?
고마워요.
나는 feed.html.erb에서 필요한 내용을 가지고 있는데 escape_javascript (????)로 어떻게 렌더링 할 수 있습니까? –