I am using an observe field that completely re-renders a page based on what language the user selects. I would like to do this and force the action into a sychronous action so when the user wants to copy the url and e-mail it to someone else, they get the same language. Any clue how to do this? If you can do it without observe_field, that would be fine with me, but it needs to happen as soon as the user picks a selection from the drop down menu. <%= f.select_tag :show_language, options_for_select(["English", "French", "Spanish"]) %> <%= observe_field(:show_language, :update => ''wrapper'',:url => {:action => :search_language, :phrase => @phrase.word}, :frequency => 0.2, :on => ''focus'', :with => "''language='' + encodeURIComponent(value)") %> Using rails 2.0.2 and leopard 10.5. -- 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 14 Jun 2008, at 04:11, Richard Schneeman wrote:> > I am using an observe field that completely re-renders a page based on > what language the user selects. I would like to do this and force the > action into a sychronous action so when the user wants to copy the url > and e-mail it to someone else, they get the same language. Any clue > how > to do this? If you can do it without observe_field, that would be fine > with me, but it needs to happen as soon as the user picks a selection > from the drop down menu. > > > <%= f.select_tag :show_language, options_for_select(["English", > "French", "Spanish"]) %> >Have you tried using the select tag''s onchange property (:onchange => remote_function(:url => {...}) ? What do you mean by forcing the action into a synchronous action ? Fred> > <%= observe_field(:show_language, :update => ''wrapper'',:url => > {:action > => :search_language, :phrase => @phrase.word}, > :frequency => 0.2, :on => ''focus'', > :with => "''language='' + encodeURIComponent(value)") %> > > > > Using rails 2.0.2 and leopard 10.5. > -- > 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 14 Jun 2008, at 04:11, Richard Schneeman wrote: > >> >> <%= select_tag :show_language, options_for_select(["English", >> "French", "Spanish"]) %> >> > Have you tried using the select tag''s onchange property (:onchange => > remote_function(:url => {...}) ? > What do you mean by forcing the action into a synchronous action ? > > FredThat is way simpler than using observe field thanks! By "forcing a synchronous action" i meant that i wanted the page to refresh totally, with a new url and everything. When i use :onchange or observe_field, i can only :update => "a_portion_of_the_page" and my url doesn''t change. So if a user used my select box to change the language from english to french and then coppied the url and sent it to someone else, when the other person clicked the url, it will incorrectly take them to the page marked as english. AJAX is awesome, but sometimes its a pain in the ass. So if you know how to force the server to re-render the entire page even if the action is triggered with ajax, let me know, thanks!! -- 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 -~----------~----~----~----~------~----~------~--~---
> > So if you know how to force the server to re-render the entire page even > if the action is triggered with ajax, let me know, thanks!!scrap the update and either: - in your rjs use page.redirect_to - or, don''t use ajax at all (ie just write the onselect yourself. you can use update_page if you can''t stand writing raw javascript) Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> scrap the update and either: > - in your rjs use page.redirect_to > - or, don''t use ajax at all (ie just write the onselect yourself. you > can use update_page if you can''t stand writing raw javascript) > > FredFrom the api, update_page doesn''t look it can be used to force my url to be changed, page.redirect_to looks promising, but i''m not familiar with rjs implementation. In rails 1.6 when passing a ajax call such as <%= link_to_remote %> it used to be as simple as passing :type => :synchronous in the code, but this doesn''t seem to work anymore, and I can''t find any info on it online. can you point me to an example? -- 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 14 Jun 2008, at 17:48, Richard Schneeman wrote:> >> scrap the update and either: >> - in your rjs use page.redirect_to >> - or, don''t use ajax at all (ie just write the onselect yourself. you >> can use update_page if you can''t stand writing raw javascript) >> >> Fred > > From the api, update_page doesn''t look it can be used to force my > url toupdate_page just creates a javascript generator (the think that rjs uses), so for example update_page do |page| page.redirect_to ... end will produce window.location = ..> > be changed, page.redirect_to looks promising, but i''m not familiar > with > rjs implementation.page.redirect_to takes the same arguments as a ''normal'' redirect_to> In rails 1.6 when passing a ajax call such as <%> link_to_remote %> it used to be as simple as passing :type => > :synchronous in the code, but this doesn''t seem to work anymore, and Irails 1.6? I think you must be imagining things. A ajax request can certainly be asynchronous or synchronous, but that''s got nothing to do with what you''re after. Fred> can''t find any info on it online. can you point me to an example? > -- > 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 -~----------~----~----~----~------~----~------~--~---