link_to_remote不起作用:使用jrails

时间:2010-09-16 08:16:58

标签: ruby-on-rails ajax jquery prototype

我正在尝试使用link_to_remote:with参数,所以我可以传递我的参数,但我使用jrails,它似乎不起作用。我使用它与jrails和原型的另一个地方,它工作得很好。这是我在jrails中的代码,我不使用原型:

<%= link_to_remote render(:partial => "back_button_text"),
   {:url => { :controller=> "content", :action => "ajax_sec_cat_display", :with => "'location=' + $("#history").html()" },
   :loading => "addSpinner()",
   :complete => "removeSpinner()"},
   :class => "menu_item back"
%>

以下是正在运行的jrails和原型:

<%= link_to_remote( "Google Map Look Up", 
      :url =>{ :action => :google_map}, 
      :with => "'location=' + $('vcompany_locations_attributes_0_address_1').value") 
   %>

1 个答案:

答案 0 :(得分:0)

我终于用这样的不引人注意的jquery做到了:

$(document).ready(function(){

$(".back").live("click", function() {
    var history = $("#history").html();
    $.ajax({
        beforeSend: function(request){addSpinner();}, 
        complete: function(request){removeSpinner()}, 
        data: 'history=' + history, 
        dataType:'script', 
        type:'post', 
        url:'/content/ajax_back_history'
    });
});
return false;

});

因此,当您单击它时,它将从历史div中获取html并将其发送到rails。我可以在控制器和rjs中使用 params [:history] ​​

唯一的问题是我没有身份验证令牌,我想知道是否有不好的事情......

相关问题