开发者

Ruby on Rails: How do I get observe_form to wait until two fields are filled before updating?

开发者 https://www.devze.com 2023-01-12 02:44 出处:网络
<%= observe_form :date_range_filter, :frequency=>0.5, :update=>\'perfomance\', :url=>{:action=>\'filter_date_range\'},
<%= observe_form :date_range_filter, 
        :frequency=>0.5,
        :update=>'perfomance',
        :url=>{:action=>'filter_date_range'},
        :before => "startLoad('perfomance');",
        :complete => "stopLoad('perfomance');" %>

I have two fields: date_after, 开发者_开发技巧and date_before

how do I get the observer to wait till both have data?


The rails doc (http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html) shows that you can use the ":condition" option with observe_form: "Use this to describe browser-side conditions when request should not be initiated.".

So something like:

:condition => "$('field1').value != '' && $('field2').value != ''"

will probably work.

0

精彩评论

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