开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜