=begin I am using Google Code Archive - Long-term storage for Google Code Project Hosting. to make date-selection easier. This is my current code. I'd like the selection of a date to trigger the observe_form and call the partial to be rendered. My current attempt is to update a hidden field within the form when a date is selected, because plain date selection did not seem to work. Did I just screw up the observe_form / form_remote_tag setup? Is there a better option for date selection which will easily trigger the observe_form? =end
## controllers/dictated_exams_controller.rb class DictatedExamsController < ApplicationController
def index @users = User.all @from = Date.new end
def filter_widget text = "" params.each { |a, b| text << "#{a} => #{b} <br />"} render :text => text
end
end
## views/dictated_exams/index.html
<center> <% form_remote_tag :html => {:id => 'input', :action => url_for(:controller => "dictated_exams", :action => "filter_widget") } do || %> <%= collection_select :widget_user, :id, @users, :id, :name, { :prompt => true } %> <%= hidden_field 'date', '' %> <%= calendar_date_select_tag "calendar", Date.today, :time => false, :valid_date_check => "date < (new Date()).stripTime()", :onchange => "date.value = $F(this)" %> <% end %> </center>
<%= observe_form :input, # The field to observe #:with => :id, # The input to validate :on => "onselect", #:frequency => 0, # The frequency in seconds to watch for changes :url => {:action => 'filter_widget', :controller => 'dictated_exams' }, # The action to call when changes occur :update => :filter_counts # Name of the <div> to update %>
<br/> <div id="filter_counts"> <%= render :text => "Results will be listed here." %> </div>