How do you attach an event listener to watch for the user to change the selected option in a ''select'' field before they click the submit button in order to instruct the page to change (AJAX) based on what the user selected in the field. In other words, I want the page to be able to change when the user makes a selection from a form select before they ever click any button. Thank you. Sam -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Sam Woodard wrote:> How do you attach an event listener to watch for the user to change the > selected option in a ''select'' field before they click the submit button > in order to instruct the page to change (AJAX) based on what the user > selected in the field. In other words, I want the page to be able > to change when the user makes a selection from a form select before they > ever click any button.Check out the observe_field method in ActionView::Helpers::PrototypeHelper In: vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Raja Venkataraman wrote:> Sam Woodard wrote: > > How do you attach an event listener to watch for the user to change the > > selected option in a ''select'' field before they click the submit button > > in order to instruct the page to change (AJAX) based on what the user > > selected in the field. In other words, I want the page to be able > > to change when the user makes a selection from a form select before they > > ever click any button. > > Check out the observe_field method in > ActionView::Helpers::PrototypeHelper > In: vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb > > -- > Posted via http://www.ruby-forum.com/.Take a look at this... http://www.sciwerks.com/blog/2006/07/07/updating-select-controls-with-ajax/ _Kevin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
_Kevin wrote:> Raja Venkataraman wrote: >> In: vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb >> >> -- >> Posted via http://www.ruby-forum.com/. > > Take a look at this... > > http://www.sciwerks.com/blog/2006/07/07/updating-select-controls-with-ajax/ > > _KevinI can''t get this plugin to work. I installed it and then wrote method: def on_prebooking_start_date_change render :update do |page| @current_two_months = two_months_starting( params[:dom_value].month, params[:dom_value].year) page.replace_html( "month_1", :partial => "month", :object => @current_two_months ) end end With the following view code: _rent.rhtml: <%= render(:partial => "month" , :object => @current_two_months) %> <%= start_form_tag :action => ''start_date'' %> <%= render(:partial => "prebooking_dates_selects") %> <%= submit_tag "Check Rate >" %> <%= end_form_tag %> _month.rhtml: <div id="month_1"> ...month 1 view html here...</div> and _pre_booking_dates_selects.rhtml: <!--[form:prebooking]--> <p><label for="prebooking_start_date">Start Date</label><br/> <%= date_select ''prebooking'', ''start_date'', :id => ''start_date'', :start_year => 2007, :end_year => Day.last_day.year, :order => [:month, :day, :year] %></p> <!--[eoform:prebooking]--> The on...change method above does nothing. ???? Sam -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
I even tried def on_prebooking_start_date_change render :update do |page| page.insert_html(:after, ''start_date'', :inline => "<span>This is working</span>" ) end end Just to see if it worked. It doesn''t! Sam -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---