[英]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 我有两个字段:date_after和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.". rails文档( http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html )显示,可以将“:condition”选项与observe_form一起使用:不被发起。”。
So something like: 所以像这样:
:condition => "$('field1').value != '' && $('field2').value != ''"
will probably work. 可能会工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.