2010-04-27 44 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()」