2010-06-02 8 views
0

Essayer de mettre dans le champ "pagar" la valeur calculée de "precio" * 15%, mais je ne sais pas pourquoi il ne fonctionne pas: SRuby on Rails - observe_field aider

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

Répondre

1

observe_field fait AJAX demandes par défaut. Je pense que vous n'avez pas besoin d'un AJAX ici, alors utilisez smth comme:

<%= observe_field :libro_precio, 
    :frequency => 0.25, 
    :update => :libro_pagar, 
    :function =>"$('libro_pagar').value = $F('libro_precio')*1.15" 
%> 
+0

Ça a marché! Merci beaucoup: D – miligraf