2010-04-27 45 views
2

我使用在轨道上经过text_field值AJX

<%= text_field 'person', 'one',:id => 'test', :onchange=>remote_function(:url=>{:action=>"update"}, :update=>"test") %> 
<div id="test"></div> 

现在,我只是想和送text_field的值:动作 即:url=>{:action=>"update(value_of_text_field_entered"}

不想使用PARAMS [:人] [:一个。

有什么建议吗?或者我该如何使用<%= observe_field%>来发送带有动作的值?

+0

请检查我的答案,并让我知道如果这不起作用。 – Salil 2010-04-27 12:53:46

回答

2

你可以试试这个也是:
<%= text_field 'person', 'one' %>

 

### Paste following code in your javascript 

$("#person_one").live("change", function(){ 
    $.ajax({ 
    complete:function(request){}, 
    data:'person_one='+ $(this).val(), 
    dataType:'script', 
    type:'get', 
    url: '/update'route 
    }) 
}); 

 
1

使用

<%= text_field 'person', 'one',:id => 'test' %> 

<%= observe_field 'persone_one', 
    :url=>{:action=>"update"} , 
:frequency => 0.25, 
    :update=>'test', 
    :with => 'person_one' 
    %> 

<div id="test"></div> 

你的PARAMS textfiled值:person_one]

1

也许你可以使用JavaScript代码, “THIS.VALUE()”