Getting value of a text Feild for ajax request Rails -
i have simple rails form looks
<%= form_for :phrase, url: phrases_path |f| %> <p> <%= f.label :"enter text" %><br> <%= f.text_area :text %> </p> <%= f.fields_for :order |builder| %> <p> <%= builder.label :"ваш email" %><br /> <%= builder.text_field :email %> </p> <% end %>
this form goes appropriate controller , in controller depending on value(text) of text area performs calculations create price , save order.
and works fine. have requirement. before submitting application user can click on button(inserted somewhere between form) know cost. said above cost calculated using text of text_area , logic present inside some method. implement button. on clicking button ajax request started, value(text) of text area retrieved , cost calculated depending on some method. calculated value shown on page.
i know start ajax request , update page. dont know how value of text_area ajax request. cannot apply in javascript since computation of cost requires some method ruby/rails dependent
Comments
Post a Comment