Passing text_field values ​​to ajx on rails

I use

<%= 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 text_field value with: action ie :url=>{:action=>"update(value_of_text_field_entered"}

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

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

+2


a source to share


3 answers


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


      

+2


a source


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 textfiled value in parameters [: person_one]

+1


a source


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

+1


a source







All Articles