. 여전히 AJAX 호출을하고있는 것처럼 들리지만, link_to_remote
동작은 불행한 부작용이있었습니다.
레일스 코드 보는 경우는 다음과 같습니다
<%= link_to "Show me", slow_page_url, :class => 'remote', :'data-update' => 'display' %>
내가 이렇게 같은 jQuery를 블록을 추가 할 : 다음
<% content_for :dom_ready do %>
// register a callback for the click event on links with class 'remote'
$('a.remote').click(function() {
// this is the clicked_link, which you may want to
// persist thru several levels of callbacks
// so assign it to a local variable
var clicked_link = this;
// assuming you already have a start_spinner function,
// and you might pass it the object where the click occured
start_spinner(clicked_link);
// here's the ajax call, which will automatically update
// the div you identified using the data-update attribute
// with the returned html
$('#'+$(this).attr('data-update')).load($(this).attr('href'), {}, function() {
//this callback only runs when the AJAX request has completed
stop_spinner(clicked_link);
});
// prevents the click event from propagating to the window object
//and moving the user away from the current page
return false;
});
<% end %>
을 나는 내 레이아웃의 하단에 내 모든 자바 스크립트로드가 좋아해
<%= javascript_include_tag 'jquery-1.3.2.js' %>
<script type="text/javascript">
$(function() {
<%= yield :dom_ready %>
);
</script>
참조 : http://stackoverflow.com/questions/18447186/rails-link-to-do-something-after-confirmation/18449331 – Yarin