Jquery jrails加载远程表单标签rails

Jquery jrails加载远程表单标签rails,jquery,ruby-on-rails,ajax,form-for,jrails,Jquery,Ruby On Rails,Ajax,Form For,Jrails,最近,我使用jrail为一个应用程序切换到jQuery。我以前使用的RJ中有99%似乎工作得很好,唯一的例外是:loading=>在使用remote\u form\u标记时的回调 <% form_remote_tag :url => '/hostels/update_currency', :loading => visual_effect(:appear, :load_currency), :html => { :id => 'currency' } do %>

最近,我使用jrail为一个应用程序切换到jQuery。我以前使用的RJ中有99%似乎工作得很好,唯一的例外是:loading=>在使用remote\u form\u标记时的回调

<% form_remote_tag :url => '/hostels/update_currency', :loading => visual_effect(:appear, :load_currency), :html => { :id => 'currency' } do %>
此html中的哪个产品:

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;">
我还尝试了回调:before和:after而不是:loading,但也没有得到任何结果。。。有什么想法吗?或者这个特性不适用于Jrail


谢谢

我发现避免内联javascript和编写简单的旧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');
    });
});
#view.html.erb
{:id=>currency'}do%>
...
#一些包含了javascript\u file.js
$(函数(){
$('#currency')。提交(函数(){
$('#加载货币')。show();//或产生效果
$.post(this.action,jQuery.param(jQuery(this.serializeArray()),function()){
$(“#加载_货币”).hide();//或执行效果
}“脚本”);
});
});

我发现避免内联javascript和编写简单的旧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');
    });
});
#view.html.erb
{:id=>currency'}do%>
...
#一些包含了javascript\u file.js
$(函数(){
$('#currency')。提交(函数(){
$('#加载货币')。show();//或产生效果
$.post(this.action,jQuery.param(jQuery(this.serializeArray()),function()){
$(“#加载_货币”).hide();//或执行效果
}“脚本”);
});
});