Ok in my view.rhtml: <% form_for :sale, :url => {:action => ''add_sale'', :id => @report}, :html => {:id => ''sales_form''} do |f| %> ... <%= f.text_field :unit_price, :size => 10 %> ... <% end %> <%= observe_form( :sales_form, :url => {:action => "update_sales_form"}, :update => :sale_unit_price) %> and in my controller: def update_sales_form render :text => "100" end ------ Now when i make a change to the form (click around, etc), it is calling "update_sales_form". But apparently I''m confused as to how to update the "unit_price" element in the DOM. Thanks for any help -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
On Wed, Oct 1, 2008 at 2:29 PM, Allen Walker <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> <%= observe_form( :sales_form, :url => {:action => "update_sales_form"}, > :update => :sale_unit_price) %>> Now when i make a change to the form (click around, etc), it is calling > "update_sales_form". But apparently I''m confused as to how to update the > "unit_price" element in the DOM.Did you mean to type: <%= observe_form( :sales_form, :url => {:action => "update_sales_form"}, :update => :unit_price) %> ^^^^^^^^^^^^^^^^^^^^^^^^^ unit_price not sale_unit_price ? Mikel -- http://lindsaar.net/ Rails, RSpec and Life blog.... --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Well I''ve tried both and it doesn''t work. My generated html source for the form: <input id="sale_unit_price" name="sale[unit_price]" size="10" type="text" /> Mikel Lindsaar wrote:> On Wed, Oct 1, 2008 at 2:29 PM, Allen Walker > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> <%= observe_form( :sales_form, :url => {:action => "update_sales_form"}, >> :update => :sale_unit_price) %> > >> Now when i make a change to the form (click around, etc), it is calling >> "update_sales_form". But apparently I''m confused as to how to update the >> "unit_price" element in the DOM. > > Did you mean to type: > > <%= observe_form( :sales_form, :url => {:action => > "update_sales_form"}, > :update => :unit_price) %> > ^^^^^^^^^^^^^^^^^^^^^^^^^ > > unit_price not sale_unit_price ? > > Mikel > > -- > http://lindsaar.net/ > Rails, RSpec and Life blog....-- 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?hl=en -~----------~----~----~----~------~----~------~--~---
On Oct 1, 8:08 am, Allen Walker <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Well I''ve tried both and it doesn''t work. My generated html source for > the form: > > <input id="sale_unit_price" name="sale[unit_price]" size="10" > type="text" />The :update option isn''t going to do much since it replaces the inner html for the tag and an input tag has no inner html. Executing some javascript along the lines of $(''sale_unit_price'').value = ... should do the trick Fred> > > > Mikel Lindsaar wrote: > > On Wed, Oct 1, 2008 at 2:29 PM, Allen Walker > > <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> <%= observe_form( :sales_form, :url => {:action => "update_sales_form"}, > >> :update => :sale_unit_price) %> > > >> Now when i make a change to the form (click around, etc), it is calling > >> "update_sales_form". But apparently I''m confused as to how to update the > >> "unit_price" element in the DOM. > > > Did you mean to type: > > > <%= observe_form( :sales_form, :url => {:action => > > "update_sales_form"}, > > :update => :unit_price) %> > > ^^^^^^^^^^^^^^^^^^^^^^^^^ > > > unit_price not sale_unit_price ? > > > Mikel > > > -- > >http://lindsaar.net/ > > Rails, RSpec and Life blog.... > > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ok .. so how exactly should I code this in my controller method? Also you are suggesting I should not have the :update option at all in my observe_form call? Frederick Cheung wrote:> On Oct 1, 8:08�am, Allen Walker <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> Well I''ve tried both and it doesn''t work. My generated html source for >> the form: >> >> <input id="sale_unit_price" name="sale[unit_price]" size="10" >> type="text" /> > > The :update option isn''t going to do much since it replaces the inner > html for the tag and an input tag has no inner html. Executing some > javascript along the lines of $(''sale_unit_price'').value = ... should > do the trick > > Fred-- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
In my controller I tried: render :text => "$(''sale_unit_price'').value = 100" no such luck Allen Walker wrote:> Ok .. so how exactly should I code this in my controller method? Also > you are suggesting I should not have the :update option at all in my > observe_form call? > > Frederick Cheung wrote: >> On Oct 1, 8:08�am, Allen Walker <rails-mailing-l...-ARtvInVfO7m5VldFQK4jKA@public.gmane.orgt> >> wrote: >>> Well I''ve tried both and it doesn''t work. My generated html source for >>> the form: >>> >>> <input id="sale_unit_price" name="sale[unit_price]" size="10" >>> type="text" /> >> >> The :update option isn''t going to do much since it replaces the inner >> html for the tag and an input tag has no inner html. Executing some >> javascript along the lines of $(''sale_unit_price'').value = ... should >> do the trick >> >> Fred-- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ok I got it to work doing: render :update do |page| page << "$(''sale_unit_price'').value = 100;" end -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
That won''t work unless you''ve removed the :update option from your observe form (and probably won''t work then since I seem to remember that prototype checks the content type of the response). An rjs (or js.erb) template or a render :update block would take care of that. Fred Sent from my iPhone On 1 Oct 2008, at 18:48, Allen Walker <rails-mailing-list@andreas- s.net> wrote:> > In my controller I tried: > > render :text => "$(''sale_unit_price'').value = 100" > > no such luck > > Allen Walker wrote: >> Ok .. so how exactly should I code this in my controller method? Also >> you are suggesting I should not have the :update option at all in my >> observe_form call? >> >> Frederick Cheung wrote: >>> On Oct 1, 8:08�am, Allen Walker <rails-mailing-l...@andreas-s.net> >>> wrote: >>>> Well I''ve tried both and it doesn''t work. My generated html >>>> source for >>>> the form: >>>> >>>> <input id="sale_unit_price" name="sale[unit_price]" size="10" >>>> type="text" /> >>> >>> The :update option isn''t going to do much since it replaces the >>> inner >>> html for the tag and an input tag has no inner html. Executing some >>> javascript along the lines of $(''sale_unit_price'').value = ... >>> should >>> do the trick >>> >>> Fred > > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---