Hello, I can''t find a way to do what I''m trying so maybe someone can throw something at me. The idea is if an option is not in a select list, the user can click a link next to the list ''not there?'' and this will open uop a text field box below. The user then enters the missing option, hits enter and the select list will update and have the new entry already selected. I can use remote_form_tag to get to send the text_field without refreshing the page but I can''t find an option as with text_field_with_auto_complete''s :after_update_element. I want to fire another Ajax request to repopulate the select list. I may already have seen the solution in my searching but I now can''t see the wood for the trees. CIA -ants -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Perhaps you can add a link_to_remote, either in the section or surrounding it, to add an extra option then update the select list. The Rails Cookbook has a section on using ajax to add DOM Elements to a page And there is this :http://api.rubyonrails.org/classes/ActionView/ Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html On Jun 22, 5:35 am, Ants Pants <antsmailingl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > I can''t find a way to do what I''m trying so maybe someone can throw > something at me. > > The idea is if an option is not in a select list, the user can click a link > next to the list ''not there?'' and this will open uop a text field box below. > The user then enters the missing option, hits enter and the select list will > update and have the new entry already selected. > > I can use remote_form_tag to get to send the text_field without refreshing > the page but I can''t find an option as with text_field_with_auto_complete''s > :after_update_element. I want to fire another Ajax request to repopulate the > select list. > > I may already have seen the solution in my searching but I now can''t see the > wood for the trees. > > CIA > > -ants-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Yeah, thanks for that. I went away yesterday and when I came back to it, I arrived at the same solution. Are you an expert with RJS? If so, I have another question. I have a select drop down list that will now be added to dynamically using RJS. But upon completion of the RJS request, all of my observer fields die (stop observing) unless I physically refresh the page. Any idea what I need to do to rectify that? On 23 June 2010 00:46, Agoofin <thebserviss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Perhaps you can add a link_to_remote, either in the section or > surrounding it, to add an extra option then update the select list. > > The Rails Cookbook has a section on using ajax to add DOM Elements to > a page > > And there is this :http://api.rubyonrails.org/classes/ActionView/ > Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html<http://api.rubyonrails.org/classes/ActionView/%0AHelpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html> > > On Jun 22, 5:35 am, Ants Pants <antsmailingl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello, > > > > I can''t find a way to do what I''m trying so maybe someone can throw > > something at me. > > > > The idea is if an option is not in a select list, the user can click a > link > > next to the list ''not there?'' and this will open uop a text field box > below. > > The user then enters the missing option, hits enter and the select list > will > > update and have the new entry already selected. > > > > I can use remote_form_tag to get to send the text_field without > refreshing > > the page but I can''t find an option as with > text_field_with_auto_complete''s > > :after_update_element. I want to fire another Ajax request to repopulate > the > > select list. > > > > I may already have seen the solution in my searching but I now can''t see > the > > wood for the trees. > > > > CIA > > > > -ants > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You need to re-add the observers in your RJS call. If you have an observer on an element with ID foo & you replace that element (page[:foo].reload), the observer goes with it. However, depending on how your observer is setup adding to the element ie another li or a subnode, can limit the need for resetting the observer. JQuery has a "live" feature that basically does this for you, albeit with a small performance overhead. Niels On Jun 23, 2010, at 6:24 AM, Ants Pants wrote:> Yeah, thanks for that. I went away yesterday and when I came back to it, I arrived at the same solution. > > Are you an expert with RJS? If so, I have another question. I have a select drop down list that will now be added to dynamically using RJS. But upon completion of the RJS request, all of my observer fields die (stop observing) unless I physically refresh the page. > > Any idea what I need to do to rectify that? > > On 23 June 2010 00:46, Agoofin <thebserviss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > Perhaps you can add a link_to_remote, either in the section or > surrounding it, to add an extra option then update the select list. > > The Rails Cookbook has a section on using ajax to add DOM Elements to > a page > > And there is this :http://api.rubyonrails.org/classes/ActionView/ > Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html > > On Jun 22, 5:35 am, Ants Pants <antsmailingl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello, > > > > I can''t find a way to do what I''m trying so maybe someone can throw > > something at me. > > > > The idea is if an option is not in a select list, the user can click a link > > next to the list ''not there?'' and this will open uop a text field box below. > > The user then enters the missing option, hits enter and the select list will > > update and have the new entry already selected. > > > > I can use remote_form_tag to get to send the text_field without refreshing > > the page but I can''t find an option as with text_field_with_auto_complete''s > > :after_update_element. I want to fire another Ajax request to repopulate the > > select list. > > > > I may already have seen the solution in my searching but I now can''t see the > > wood for the trees. > > > > CIA > > > > -ants > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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. > > > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Good timing, just came to check my replies. Thanks for the heads up on that, I''ll give it a go. I hate frontend development!! Whatever was wrong with static HTML?!! ;) On 23 June 2010 14:16, Niels Meersschaert <nmeersschaert-ee4meeAH724@public.gmane.org> wrote:> You need to re-add the observers in your RJS call. If you have an observer > on an element with ID foo & you replace that element (page[:foo].reload), > the observer goes with it. However, depending on how your observer is setup > adding to the element ie another li or a subnode, can limit the need for > resetting the observer. > > JQuery has a "live" feature that basically does this for you, albeit with a > small performance overhead. > > Niels > > On Jun 23, 2010, at 6:24 AM, Ants Pants wrote: > > Yeah, thanks for that. I went away yesterday and when I came back to it, I > arrived at the same solution. > > Are you an expert with RJS? If so, I have another question. I have a select > drop down list that will now be added to dynamically using RJS. But upon > completion of the RJS request, all of my observer fields die (stop > observing) unless I physically refresh the page. > > Any idea what I need to do to rectify that? > > On 23 June 2010 00:46, Agoofin <thebserviss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Perhaps you can add a link_to_remote, either in the section or >> surrounding it, to add an extra option then update the select list. >> >> The Rails Cookbook has a section on using ajax to add DOM Elements to >> a page >> >> And there is this :http://api.rubyonrails.org/classes/ActionView/ >> Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html<http://api.rubyonrails.org/classes/ActionView/%0AHelpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html> >> >> On Jun 22, 5:35 am, Ants Pants <antsmailingl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > Hello, >> > >> > I can''t find a way to do what I''m trying so maybe someone can throw >> > something at me. >> > >> > The idea is if an option is not in a select list, the user can click a >> link >> > next to the list ''not there?'' and this will open uop a text field box >> below. >> > The user then enters the missing option, hits enter and the select list >> will >> > update and have the new entry already selected. >> > >> > I can use remote_form_tag to get to send the text_field without >> refreshing >> > the page but I can''t find an option as with >> text_field_with_auto_complete''s >> > :after_update_element. I want to fire another Ajax request to repopulate >> the >> > select list. >> > >> > I may already have seen the solution in my searching but I now can''t see >> the >> > wood for the trees. >> > >> > CIA >> > >> > -ants >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.