我正在尝试构建一个表单字段,可以接受文本输入,也可以从下拉列表中选择一个选项。在rails中,自动完成插件接近我的需要,除了我希望在用户在文本字段中键入任何内容之前可以使用下拉列表。某处有这样的例子吗?
请求帮助,
-C
答案 0 :(得分:0)
我在视图上使用此代码来选择日期或输入名称(我希望您阅读HAML):
%center
- form_remote_tag :update => 'filter_counts', :url => { :action => 'name_filter', :controller => 'dictated_exams', :method => :post } do
Please enter part of a name ('%' is the wildcard character):
= text_field_tag 'search', nil, :maxlength => 15, :size => 15
= submit_tag 'Search'
%b OR
pick the exam date:
= calendar_date_select_tag "date", Date.today, :time => false, :valid_date_check => "date < (new Date()).stripTime()"
= image_tag "spinner.gif", :align => "absmiddle", :border => 0, :id => "spinner", :style => "display: none;"
= observe_field :date, :with => :date, :frequency => 1, :url => {:action => 'filter_widget', :controller => 'dictated_exams', :method => :post }, :update => :filter_counts, :before => "Element.show('spinner')", :success => "Element.hide('spinner')"
另一方面,也许你只是在寻找这个: Rails' observe_form method 基本上,问题是:你需要将这两种方法输入到一个表单中,还是可以分开?如果是这样,您也可以单独观看它们。