[英]Passing a collection_selection and text_field values in a form_for, rails
[英]passing text_field values in ajx on rails
我正在使用
<%= text_field 'person', 'one',:id => 'test', :onchange=>remote_function(:url=>{:action=>"update"}, :update=>"test") %>
<div id="test"></div>
現在,我只想發送帶有:action的text_field的值,即:url=>{:action=>"update(value_of_text_field_entered"}
不想使用params [:person] [:one]。
有什么建議嗎?或者如何使用<%= observe_field%>通過操作發送值?
您也可以嘗試以下方法:
<%= 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
})
});
采用
<%= 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中獲得textfile的值[:person_one]
也許您可以使用JavaScript代碼“ this.value()”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.