我在 Rails 3.2.5 中使用 simple_form。我有一个看起来像这样的表格:
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'form-vertical' }, :html => {:name => "new_user"}) do |f| %>
<%= f.error_notification %>
<%= f.input :field_one,
:placeholder => '30000',
:autofocus => true,
:required => true,
:html => {:onFocus => 'startCalc();'},
:html => {:onBlur => 'stopCalc();'} %>
# More form fields
<% end %>
当用户在表单字段中输入数字时,我试图调用 Javascript 驱动的计算,但 Javascript 未显示在输出的 HMTL 中:
<input autofocus="autofocus" class="numeric decimal required" id="field_one" name="user[field_one]" placeholder="30000" step="any" type="number" />
有谁知道如何让 simple_form 添加这些 Javascript 位?
谢谢!
格雷格