开发者

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"
%>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜