2009-12-02 2 views
1

최근 jRails를 사용하여 jQuery로 전환했습니다. 내 모든 이전 RJS의 99 %가 완벽하게 작동하는 것 같습니다. 단, remote_form_tag를 사용할 때 : loading => 콜백이 예외입니다. jrails loading remote_form_tag rails

<% form_remote_tag :url => '/hostels/update_currency', :loading => visual_effect(:appear, :load_currency), :html => { :id => 'currency' } do %> 

나는이 기능이 작동하지 않는 것, 제공된 프로토 타입 도우미

http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001648

을 사용하지만 새로운 jRails 대안을 사용하기 전에 완벽하게 일을 숨겨진 DIV의 #load_currency 있나요?

나는 RJS 직접 jQuery를 사용하여 시도 :

이는 HTML에서 제품
:loading => visual_effect(:appear, :load_currency) 
:loading => "$('#load_currency').show();" 

:

onsubmit="jQuery.ajax({beforeSend:function(request){jQuery(&quot;#load_currency&quot;).fadeIn();}, data:jQuery.param(jQuery(this).serializeArray()) + '&amp;authenticity_token=' + encodeURIComponent('O7Y7wzFoPPxGSTxIb2bQ3zshrUP+h1OGAUdtyzdQz0A='), dataType:'script', type:'post', url:'/hostels/update_currency'}); return false;"> 

가 나는 또한 콜백을 시도 : 전 : 대신 후 :로드 및도있어 아무것도 아냐 ... 어떤 생각? 또는이 기능은 jRails에서 작동하지 않습니까?

덕분에

답변

1

나는 그것이 청소기 평범한 구식 jQuery를 쓰기 자바 스크립트와 인라인을 피하기 위해 찾을 수 있습니다. 다음과 같이 시도해보십시오.

# view.html.erb 
<% form_tag '/hostels/update_currency', :html => { :id => 'currency' } do %> 
... 


# some_included_javascript_file.js 
$(function() { 
    $('#currency').submit(function() { 
     $('#load_currency').show(); // or do an effect 
     $.post(this.action, jQuery.param(jQuery(this).serializeArray()), function() { 
      $('#load_currency').hide(); // or do an effect 
     }, 'script'); 
    }); 
});