Forum: Ruby on Rails how to escape from AJAX URL

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
515898082d7e6c89dc58ef017d1c311e?d=identicon&s=25 Fish Man (fishman2001)
on 2006-02-22 11:00
This may be a bit difficult to explain, but here goes.

I'm developing a web site which has a nice AJAX part to it (thanks to
rails). You just click on the link and it take you to the ajax part
which is on a seperate page.

-The user then selects directories or files from via a multiple menu.

-When the user selects a directory (and hits the submit button) the menu
is updated with the next directory selected.

-When the user selects a file (and hits the submit button) the
application should go back to the previous page and display the file
he/she selected.

OK this does work apart from the fact that after the file is selected
and the page goes back, the URL is still displaying the AJAX enhanced
page. I'd like it to display the URL of the page it went back to
otherwise I know the user will start to question this.

does anyone know how to escape from that?


Cheers.
1843ba3c4ff9cc702bc3474223a0acc6?d=identicon&s=25 Tony Jin (tony)
on 2006-02-22 15:45
fish man wrote:
> This may be a bit difficult to explain, but here goes.
>
> I'm developing a web site which has a nice AJAX part to it (thanks to
> rails). You just click on the link and it take you to the ajax part
> which is on a seperate page.
>
> -The user then selects directories or files from via a multiple menu.
>
> -When the user selects a directory (and hits the submit button) the menu
> is updated with the next directory selected.
>
> -When the user selects a file (and hits the submit button) the
> application should go back to the previous page and display the file
> he/she selected.
>
> OK this does work apart from the fact that after the file is selected
> and the page goes back, the URL is still displaying the AJAX enhanced
> page. I'd like it to display the URL of the page it went back to
> otherwise I know the user will start to question this.
>
> does anyone know how to escape from that?
>
>
> Cheers.


I think the last step you can use redirect the whole page to the one you
want instead of using Ajax to update part of it.

-Tony
515898082d7e6c89dc58ef017d1c311e?d=identicon&s=25 Fish Man (fishman2001)
on 2006-02-22 17:01
yes I did try that, using redirect_to :action => 'blahblahblah'
but the URL was still the Ajax page so if you hit refresh it goes back
to the original ajax page. but if i hit the back button it gives me what
I want.


Tony Jin wrote:
> fish man wrote:
>> This may be a bit difficult to explain, but here goes.
>>
>> I'm developing a web site which has a nice AJAX part to it (thanks to
>> rails). You just click on the link and it take you to the ajax part
>> which is on a seperate page.
>>
>> -The user then selects directories or files from via a multiple menu.
>>
>> -When the user selects a directory (and hits the submit button) the menu
>> is updated with the next directory selected.
>>
>> -When the user selects a file (and hits the submit button) the
>> application should go back to the previous page and display the file
>> he/she selected.
>>
>> OK this does work apart from the fact that after the file is selected
>> and the page goes back, the URL is still displaying the AJAX enhanced
>> page. I'd like it to display the URL of the page it went back to
>> otherwise I know the user will start to question this.
>>
>> does anyone know how to escape from that?
>>
>>
>> Cheers.
>
>
> I think the last step you can use redirect the whole page to the one you
> want instead of using Ajax to update part of it.
>
> -Tony
Ff82af3238a57fbd1212832ec1a19f28?d=identicon&s=25 Dylan Stamat (Guest)
on 2006-02-22 17:09
(Received via mailing list)
use RJS templates... I had this "exact" problem, but RJS did the trick.
within my "login.rjs" template that get's invoked after my login
process, it
returns to the same page with an error message on error, or... if the
login
was successful, it needs to "redirect" to another controller... which is
pretty much impossible to do otherwise.  so, my "login.rjs" looks like:

if @logged_in_client
  page.replace_html "message", :partial => 'shared/bad_login'
else
  page.redirect_to "whatever you want here"
end

i was scared to use edge rails at first, but now i swear by it :)
This topic is locked and can not be replied to.