hi guys: I''m scratching my head on this one: I have a twitter app where I''m trying to open a modalpopup with a twitter sign in, get them to sign in, then close the popup and refresh the main window. My code however refreshes the main window with the popup window result, which I thought was really strange: application.html.erb function OpenModalPopUP() { window.showModalDialog(''/sessions/create''); } main page <%= link_to "login via twitter", {:controller => "sessions/create"}, :onclick => "OpenModalPopUP()" %> sessions/create def create oauth.set_callback_url(finalize_session_url) session[''rtoken''] = oauth.request_token.token session[''rsecret''] = oauth.request_token.secret redirect_to oauth.request_token.authorize_url end sessions/finalize def finalize oauth.authorize_from_request(session[''rtoken''], session[''rsecret''], params[:oauth_verifier]) session[''rtoken''] = nil session[''rsecret''] = nil profile = Twitter::Base.new(oauth).verify_credentials user = User.find_or_create_by_screen_name(profile.screen_name) user.update_attributes({ :atoken => oauth.access_token.token, :asecret => oauth.access_token.secret, }) sign_in(user) # page << "window.close()" redirect_to session[:return_to] rescue redirect_to :controller => "home" # redirect_to :controller => "sessions/autoclose" end As you can see, by the commented out code, I attempted to push "window.close()" but it gave me an error message. i then tried to redirect to another window which autoclosed, but when I did that, it redirected the main window to autoclose as well. I''m a rails noob, so I''m guessing that i have to do something after the redirect to shut down the process after closing the window, otherwise it will run the refresh on the main window? Please advise. also, while i''m at it, do you know how I can resize the modalpopup? Thanks...chris -- 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-/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.
Here is something to close modalbox, rjs: page.call ''Modalbox.hide();'' On Jul 1, 12:49 pm, Chris Kalaboukis <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> hi guys: > > I''m scratching my head on this one: I have a twitter app where I''m > trying to open a modalpopup with a twitter sign in, get them to sign in, > then close the popup and refresh the main window. My code however > refreshes the main window with the popup window result, which I thought > was really strange: > > application.html.erb > > function OpenModalPopUP() > { > window.showModalDialog(''/sessions/create''); > > } > > main page > > <%= link_to "login via twitter", {:controller => "sessions/create"}, > :onclick => "OpenModalPopUP()" %> > > sessions/create > > def create > > oauth.set_callback_url(finalize_session_url) > > session[''rtoken''] = oauth.request_token.token > session[''rsecret''] = oauth.request_token.secret > > redirect_to oauth.request_token.authorize_url > end > > sessions/finalize > > def finalize > oauth.authorize_from_request(session[''rtoken''], session[''rsecret''], > params[:oauth_verifier]) > > session[''rtoken''] = nil > session[''rsecret''] = nil > > profile = Twitter::Base.new(oauth).verify_credentials > user = User.find_or_create_by_screen_name(profile.screen_name) > > user.update_attributes({ > :atoken => oauth.access_token.token, > :asecret => oauth.access_token.secret, > }) > > sign_in(user) > # page << "window.close()" > redirect_to session[:return_to] rescue redirect_to :controller => > "home" > # redirect_to :controller => "sessions/autoclose" > end > > As you can see, by the commented out code, I attempted to push > "window.close()" but it gave me an error message. i then tried to > redirect to another window which autoclosed, but when I did that, it > redirected the main window to autoclose as well. I''m a rails noob, so > I''m guessing that i have to do something after the redirect to shut > down the process after closing the window, otherwise it will run the > refresh on the main window? Please advise. > > also, while i''m at it, do you know how I can resize the modalpopup? > > Thanks...chris > -- > 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-/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.
Chris Habgood wrote:> Here is something to close modalbox, rjs: > > page.call ''Modalbox.hide();''Thanks Chris... this is what I get when I try that: undefined local variable or method `page'' for #<SessionsController:0xb6e8a204> any ideas? -- 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-/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.
Chris Kalaboukis wrote:> Chris Habgood wrote: >> Here is something to close modalbox, rjs: >> >> page.call ''Modalbox.hide();'' > > Thanks Chris... this is what I get when I try that: > > undefined local variable or method `page'' for > #<SessionsController:0xb6e8a204> > > any ideas?also tried this: render :update do |page| page.call ''Modalbox.hide();'' end but then got this error try { Modalbox.hide();(); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''Modalbox.hide();();''); throw e } When i closed the modal box manually, it refreshed the main window with the saem error -- 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-/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.
can anyone help me here. i assume that there is a way to do this... -- 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-/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 can see this being the error Modalbox.hide();(); Use this way render :update do |page| page << ''Modalbox.hide();'' end OR this.. render :update do |page| page.call ''Modalbox.hide'' end regards, Sur http://crimson9.com On Jul 2, 10:37 am, Chris Kalaboukis <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> can anyone help me here. i assume that there is a way to do this... > -- > 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-/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.
Sur Max wrote:> You can see this being the error > > Modalbox.hide();(); > > Use this way > > render :update do |page| > page << ''Modalbox.hide();'' > end > > OR this.. > > render :update do |page| > page.call ''Modalbox.hide'' > end > > > regards, > Sur > http://crimson9.comTried it both ways, I still get this: this: render :update do |page| page << ''Modalbox.hide();'' end gives this: try { Modalbox.hide(); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''Modalbox.hide();''); throw e } and this render :update do |page| page.call ''Modalbox.hide'' end gives this: try { Modalbox.hide(); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''Modalbox.hide();''); throw e } Any ideas? Thanks for your help so far.... Thanks...Chris -- 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-/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.