Ruby on Rails - observe_field help
Trying to put in field "pagar" the calculated value of "precio" * 15% but I don't know why it is not working :S
<% form_for @libro, :html => { :multipart => true } do |f| %>
<%= f.label "Precio (si es venta):" %>
<%= f.text_field :precio %>
<%= observe_field :libro_precio,
:frequency => 0.25,
:update => :libro_pagar,
:with => 'value开发者_运维技巧*0.15'
%>
<%= f.label "A pagar (si es venta):" %>
<%= f.text_field :pagar %>
<% end %>
observe_field makes AJAX requests by default. I think you don't need an AJAX here, so use smth like:
<%= observe_field :libro_precio,
:frequency => 0.25,
:update => :libro_pagar,
:function =>"$('libro_pagar').value = $F('libro_precio')*1.15"
%>
加载中,请稍侯......
精彩评论