开发者

passing text_field values in ajx on rails

开发者 https://www.devze.com 2022-12-28 02:39 出处:网络
I\'m using <%= text_field \'person\', \'one\',:id => \'test\', :onchange=>remote_function(:url=>{:action=>\"update\"}, :update=>\"test\") %>

I'm using

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

Now I just want to send the value of text_field with :action i.e :url=>{:action=>"updat开发者_如何学运维e(value_of_text_field_entered"}

Don't want to use params[:person][:one].

Any suggestions?or how can I use <%= observe_field %> to send the value with action?


You can try this one also:
<%= 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
  })
});



maybe you can use a javascript code, "this.value()"


Use

<%= 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>

you get value of textfiled in params[:person_one]

0

精彩评论

暂无评论...
验证码 换一张
取 消