Thursday, September 23, 2010

[Rails] Re: how to make an ajax call to redirect

Sjoerd Andringa wrote:
> Hi daociyiyou ,
>
> Try this:
>
> def find_created_actions
> unless @if_login
> flash[:login]="..."
> redirect_to(:controller=>"login",:action=>"login")
> end
> if @if_login
> @user_cactions=@user.sponsored_actions
> render :update do |page|
> page.replace_html 'element_id',
> :partial => "created_actions", :object => @user_cactions
> end
> else
> render :update do |page|
> page.redirect_to(:controller=>"login",:action=>"login")
> end
> end
> end
>
> And make sure you're *not* using the :update option on your remote_form.
> 'page.redirect_to()' will generate javascript similar to Hassan's
> aforementioned suggestion.

Hi, just a note that this does not work. Because the redirect gets
trapped inside the Ajax call. If you use firebug you can see what
happens.

So it seems the only way to redirect is to use a javascript redirect as
mentioned on:
http://stackoverflow.com/questions/1215177/cannot-do-response-redirect-from-page-with-ajax-controls
--
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@googlegroups.com.
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate