Eric Sloane
2006-Jan-06 06:35 UTC
[Rails] NewbieQ: How do I refresh view after return from popup window
Hi, I have this bitta code that is supposed to open a new window and allow the user to create a new Organisation on the fly whilst editing a new Person i.e. if the Organisation exists they can select it from the drop down select. Otherwise they can click on the cute button and enter a skeleton Organisation record. What I need to do next is refresh the drop down select on returno the new organisation is shown and selected. I have no idea how to do that - Any ideas? BTW - I''m not yet using AJAX Usual Person data... Name, Position, etc Then; <td> <%= link_to(image_tag("new_organisation.png", :alt => ''New'', :border =>1), { :controller => ''organisations'', :action => ''new''}, :popup => [''new_window'', ''height=100,width=100'']) %> <select id="person.organisation_id" name="person[organisation_id]"> <%= options_from_collection_for_select @org, "id", "organisation_name", @person.organisation_id %> </select></p> </td>
I would be very interested in this question too........has anybody figured this out? Thanks Victor Eric Sloane wrote:> Hi, > I have this bitta code that is supposed to open a new window and allow > the user to create a new Organisation on the fly whilst editing a new > Person i.e. if the Organisation exists they can select it from the drop > down select. Otherwise they can click on the cute button and enter a > skeleton Organisation record. What I need to do next is refresh the drop > down select on returno the new organisation is shown and selected. > > I have no idea how to do that - Any ideas? BTW - I''m not yet using AJAX > > > Usual Person data... Name, Position, etc > Then; > <td> > <%= link_to(image_tag("new_organisation.png", :alt => ''New'', > :border =>1), > { :controller => ''organisations'', :action => ''new''}, > :popup => [''new_window'', ''height=100,width=100'']) %> > <select id="person.organisation_id" name="person[organisation_id]"> > <%= options_from_collection_for_select @org, > "id", "organisation_name", @person.organisation_id %> </select></p> > </td>-- 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 -~----------~----~----~----~------~----~------~--~---
Kad Kerforn
2006-Oct-02 21:51 UTC
Re: NewbieQ: How do I refresh view after return from popup w
I''d be too.. will try tomorrow.. with some Ajax request... Victor wrote:> I would be very interested in this question too........has anybody > figured this out? > > Thanks > Victor >-- 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 -~----------~----~----~----~------~----~------~--~---
Bill Walton
2006-Oct-02 21:59 UTC
Re: NewbieQ: How do I refresh view after return from popup w
> Eric Sloane wrote:>> What I need to do next is refresh the drop >> down select on returno the new organisation >> is shown and selected. >> >> I have no idea how to do that - Any ideas? >> BTW - I''m not yet using AJAXYou need to be using Ajax (probably via RJS). Put the drop-down in a <div> and re-render it after you''re done entering the new Org record. To learn RJS, I strongly recommend Cody Fauser''s "RJS Templates" PDF from O''Reilly. One of the best $10 I ever spent to learn a new programming tool / technique. hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
AJAX seems like a good option here. But if you don''t want to get into that and don''t mind the whole page being refreshed you could also try something like this: - Add a hidden field to your form called "organisation_added" which is set to false by default. - Then when an organisation is added, use JavaScript to set "organisation_added" to true and post the form. - Then with Ruby, if params[''organisation_added''] is set to true create a person object using the data that has already been entered (@person Person.new(params[:person]) ), and re-render the form. - params[''organisation_added''] == false means the user posted the form manually, so in that case you can save the person to your DB. Good luck! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi> - Then when an organisation is added, use JavaScript to set > "organisation_added" to true and post the form. >How to do this bit? In particular how to use javascript from the popup to reference the page it was popped up from. Also how to set the field and post the form whilst not loosing any of the data already entered? In my case I want to let the user enter som Lat/Lon position data, OR for convenience popup a google maps object and have it fill in the details in the original form when the user clicks on a location. I don''t feel that I need to post the form, just figure out how to reference back from the popped up page back to the original page? Cheers Ed W --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
In Javascript window.opener is your reference to the parent window, i.e. the window it was popped up from. Example: In your main page where the form exists: <input type="hidden" id="person_haircolour" name="person[haircolour]" value="#FFFFFF"/><!-- This guy must be an albino! lol --> In the pop-up page: <input type="button" onclick="window.opener.getElementById(''person_haircolour'').value selectedColour; window.close();" /> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Possibly Parallel Threads
- A quick question on popup windows
- find :order =>
- Unknown column 'quotes.organisation_id' in 'where clause': SELECT * FROM `quotes` WHERE (`quotes`.organisation_id = 1036)
- NewbieQ: How do you specify a name for a form
- find (ordering by field in related table)