Hello, In my view I use an autocomplete textfield, exactly as described on http://www.slash7.com/articles/2005/8/13/ajaxariffic-autocomplete-with-scriptaculous. I implemented a method, say auto_complete_for_model_field which renders the partial ''models'': <code> def auto_complete_for_model_field ... render :partial => ''models'' end </code> This works as expected, however instead of rendering a .rhtml I want to use a rjs template, but how do I position the list shown by the auto_complete... method? -- 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 -~----------~----~----~----~------~----~------~--~---
Hi, you can do one of the following: a) respond_to block e.g. def product respond_to do | format | format.html format.js { render :action => "project.rjs" } format.xml end end Note: This will return the appropriate response based on the HTTP Accept header. b) render :action => "product.rjs" Good luck, -Conrad On 12/18/06, Patrick Baselier <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hello, > > In my view I use an autocomplete textfield, exactly as described on > > http://www.slash7.com/articles/2005/8/13/ajaxariffic-autocomplete-with-scriptaculous > . > I implemented a method, say auto_complete_for_model_field which renders > the partial ''models'': > <code> > def auto_complete_for_model_field > ... > render :partial => ''models'' > end > </code> > > This works as expected, however instead of rendering a .rhtml I want to > use a rjs template, but how do I position the list shown by the > auto_complete... method? > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Hi, you can also find further information in section 12.1 of the ''Agile Web Development with Rails 2ed''. -Conrad On 12/18/06, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, you can do one of the following: > > a) respond_to block > > e.g. def product > respond_to do | format | > format.html > format.js { render :action => "project.rjs" } > format.xml > end > end > > Note: This will return the appropriate response based on > the HTTP Accept header. > > b) render :action => "product.rjs" > > Good luck, > > -Conrad > > On 12/18/06, Patrick Baselier <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > > > Hello, > > > > In my view I use an autocomplete textfield, exactly as described on > > > > http://www.slash7.com/articles/2005/8/13/ajaxariffic-autocomplete-with-scriptaculous > > . > > I implemented a method, say auto_complete_for_model_field which renders > > the partial ''models'': > > <code> > > def auto_complete_for_model_field > > ... > > render :partial => ''models'' > > end > > </code> > > > > This works as expected, however instead of rendering a .rhtml I want to > > use a rjs template, but how do I position the list shown by the > > auto_complete... method? > > > > -- > > 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 -~----------~----~----~----~------~----~------~--~---
Conrad Taylor wrote:> Hi, you can also find further information in section 12.1 of the ''Agile > Web > Development with Rails 2ed''. > > -ConradHi Conrad, Although respond_to is very interesting, this is not what I''m looking for. What I want is, when typing a character into an autocomplete textbox, I also want to show a Save button, which is initially hidden. Now I use this approach: # view <%= text_field_with_auto_complete :model, :field %> <%= observe_field("model_field", :frequency => 0.1, :url => { :action => :show_save } ) %> <div id="save_div" style="display: none;">Show this later</div> # controller auto_complete_for :contact, :name def show_save render :update do |page| page.show ''save_div'' end end The Observe tag looks for changes in the autocomplete textbox and triggers a method named show_save. The show_save method displays the element named ''save_div'' which containts the text ''Show this later''. This is working, however I wonder if this can be accomplished using 1 method named auto_complete_for_model_field which displays the autocomplete list AND show the ''save_div'' element. One step futher (and a little off topic): After displaying de ''save_div'' element I want the Observer to stop observing. I tried to nest the observe_field into a div-element (say: ''observe_div'') and let this be removed when the show_save method is called: def show_save render :update do |page| page.show ''save_div'' page.remove ''observe_div'' end end The element is deleted, but the textbox is still being observed. -- 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 -~----------~----~----~----~------~----~------~--~---