Forum: Ruby on Rails Ajax Button Back function?

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.
42254d96a59d16f649dc768b46722599?d=identicon&s=25 Junior Marçal (jcalled)
on 2006-01-12 05:14
Hi Folks! I'm new in the forum and i have a doubt. The button back
function with the Ajax on Rails?  tks.
205bc8d44e9bc5c68d77dd412abcb3ce?d=identicon&s=25 Dan Shafer (Guest)
on 2006-01-12 06:08
(Received via mailing list)
Your question is a *little* vague but I'll assume I understand it.

Any AJAX stuff you do essentially "breaks" the back button in the
sense that the browser doesn't "know" about the incremental page
changes taking place via AJAX. So if you go from Page A to Page B and
then update three HTML elements on Page B and hit the Back button in
the browser, you're back at Page A (and presumably all your changes
to Page B are gone).

That's one of the main criticisms of using AJAX; it breaks the basic
navigational paradigm. It's not *hard* to design your Web apps so
that this doesn't become an issue (always open your AJAX pages in a
new window and confine your AJAX apps -- or logical segments thereof
-- to single pages), but it does require some additional thinking.

HTH,

On Jan 11, 2006, at 8:14 PM, Junior Marçal wrote:

> Hi Folks! I'm new in the forum and i have a doubt. The button back
> function with the Ajax on Rails?  tks.
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
Dan Shafer
Technology Visionary - Technology Assessment - Documentation
"Looking at technology from every angle"
http://www.eclecticity.com
F7a2f59c93fae91cb2c9a44060b34a13?d=identicon&s=25 Jesse Farmer (vann)
on 2006-01-12 06:47
(Received via mailing list)
Junior Marçal wrote:
> Hi Folks! I'm new in the forum and i have a doubt. The button back
> function with the Ajax on Rails?  tks.


A properly designed page should not use AJAX in such a way that the back
button is broken.  If you have two pages which logically should be
referenced via different URLs, i.e., they're actually difference
resources, then you shouldn't be transferring from one to the other with
AJAX.

AJAX should only be used to edit in-page items.  For example, if you
have a form which sends mail then a sensible use of AJAX would be to
send the email asynchronously and change the input forms to a success
message when complete.  Another example would be in-place editing of
lists, say, of bookmarks.


--
Jesse Farmer <farmerje@uchicago.edu>
University of Chicago - NSIT Web Services
AIM:    farmerje
Jabber: farmerje@im.uchicago.edu
Phone:  (773)363-1058
Ee508a7b3a54d899378eaccc50b25c3f?d=identicon&s=25 Tyler Kovacs (Guest)
on 2006-01-12 07:07
(Received via mailing list)
Junior Marçal <jcalled@...> writes:

>
> Hi Folks! I'm new in the forum and i have a doubt. The button back
> function with the Ajax on Rails?  tks.

There are way to preserve state across page views so that browser
history (back
and forward buttons) and bookmarking works in javascript/AJAX
applications.
Some AJAX frameworks, such as the DOJO toolkit, include a history
mechanism.
The javascript libraries that ship with Rails (prototype and
script.aculo.us) do
not, so you'll have to write one yourself.  Read this blog post if you
want to
learn more about how to do it:

http://codinginparadise.org/weblog/2005/08/ajax-tu...

I've had a mixed experience implementing the approach detailed in that
blog
post.  Everything works great out of the box in Firefox (and Safari
IIRC), but
IE was a nightmare.  IE doesn't repopulate form values (the basis of the
history
mechanism in the post above) unless you've got your cache HTTP headers
(cache-control and IE-specific ETag) set in the response.  But caching
doesn't
work well if the page in question has dynamic content.  IE also refused
to
repopulate form values in iframes even with the cache control header set
making
it impossible to separate dynamic content from the content that requires
the
history mechanism.

Tyler
C9af522fc39d5de90f21119543c2b9ab?d=identicon&s=25 Steve Litt (Guest)
on 2006-01-12 15:50
(Received via mailing list)
On Thursday 12 January 2006 12:44 am, Jesse Farmer wrote:
> AJAX should only be used to edit in-page items.  For example, if you
> have a form which sends mail then a sensible use of AJAX would be to
> send the email asynchronously and change the input forms to a success
> message when complete.  Another example would be in-place editing of
> lists, say, of bookmarks.

How bout field level validation?

SteveT

Steve Litt
Author:
   * Universal Troubleshooting Process courseware
   * Troubleshooting Techniques of the Successful Technologist
   * Rapid Learning: Secret Weapon of the Successful Technologist
Webmaster
   * Troubleshooters.Com
   * http://www.troubleshooters.com
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-01-12 15:59
(Received via mailing list)
Steve Litt wrote:
> How bout field level validation?
>
As long as you don't absolutely rely on it, I can't see any reason not
to use it...
F7a2f59c93fae91cb2c9a44060b34a13?d=identicon&s=25 Jesse Farmer (vann)
on 2006-01-12 16:51
(Received via mailing list)
Steve Litt wrote:
>> AJAX should only be used to edit in-page items.  For example, if you
>> have a form which sends mail then a sensible use of AJAX would be to
>> send the email asynchronously and change the input forms to a success
>> message when complete.  Another example would be in-place editing of
>> lists, say, of bookmarks.
>
> How bout field level validation?


Sure, why not?  You have some form to create, say, a listing which
submits the data asynchronously to ListingController's create method.
Any errors can be fetched asynchronously, and on success you can delete
all the form elements and display a "success" message.  The create
method could re-render the form entirely so you get the fancy CSS stuff
Rails does, and you just blank the old form and replace it with the
asynchronously fetched form.

I actually think AJAX can be used to unbreak the back button.  Many
times you're in a state where going back takes you to stale data.  This
can be dangerous in the case of submitting a form where there is the
potential for submitting the data twice, either by going back from the
"success" page or by hitting refresh on the "success" page, thereby
POSTing all over again.


--
Jesse Farmer <farmerje@uchicago.edu>
University of Chicago - NSIT Web Services
AIM:    farmerje
Jabber: farmerje@im.uchicago.edu
Phone:  (773)363-1058
30269682335f1fb247d71969fa715b5e?d=identicon&s=25 Roberto Saccon (rsaccon)
on 2006-01-12 17:21
(Received via mailing list)
For ajax form validation, you should consider RJS, as described at
techno-weenie<http://rails.techno-weenie.net/tip/2005/11/29/ajax...
F7a2f59c93fae91cb2c9a44060b34a13?d=identicon&s=25 Jesse Farmer (vann)
on 2006-01-12 17:30
(Received via mailing list)
Roberto Saccon wrote:
> For ajax form validation, you should consider RJS, as described at
> techno-weenie
> <http://rails.techno-weenie.net/tip/2005/11/29/ajax...

That's pretty cool.  I'll have to look into it!

--
Jesse Farmer <farmerje@uchicago.edu>
University of Chicago - NSIT Web Services
AIM:    farmerje
Jabber: farmerje@im.uchicago.edu
Phone:  (773)363-1058
67cb6fef42a83929955ce5a5b3f33f6e?d=identicon&s=25 Jon Smirl (Guest)
on 2006-01-15 03:13
(Received via mailing list)
On 1/11/06, Junior Marçal <jcalled@gmail.com> wrote:
> Hi Folks! I'm new in the forum and i have a doubt. The button back
> function with the Ajax on Rails?  tks.

AJAX: How to Handle Bookmarks and Back Buttons
by Brad Neuberg
10/26/2005

This article presents an open source JavaScript library that finally
brings bookmarking and back button support to AJAX applications. By
the end of this tutorial, developers will have a solution to an AJAX
problem that not even Google Maps or Gmail possesses: robust, usable
bookmarking and back and forward behavior that works exactly like the
rest of the Web.

http://www.onjava.com/pub/a/onjava/2005/10/26/ajax...

>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Jon Smirl
jonsmirl@gmail.com
235c58ad566abb4c7979bc7033e9882c?d=identicon&s=25 David Morton (Guest)
on 2006-01-25 00:24
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jesse Farmer wrote:

> I actually think AJAX can be used to unbreak the back button.  Many
> times you're in a state where going back takes you to stale data.  This
> can be dangerous in the case of submitting a form where there is the
> potential for submitting the data twice, either by going back from the
> "success" page or by hitting refresh on the "success" page, thereby
> POSTing all over again.

This is better solved by using redirects after a submit operation, then
the
update page is never available for a reload.


- --
David Morton
Maia Mailguard                        - http://www.maiamailguard.com
Morton Software Design and Consulting - http://www.dgrmm.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFD1raJSIxC85HZHLMRArJ1AJ0Tw9ZwwWWXJYvmqvnRlkv2VBhTEQCfWhkg
+ZRGqYQA5mGcHBf9YHgIKl8=
=oleG
-----END PGP SIGNATURE-----
1223d8b5d822fa977e2fd53511d543a3?d=identicon&s=25 Dominic (Guest)
on 2006-11-11 03:27
I'm actually trying out this tutorial at
http://www.onjava.com/pub/a/onjava/2005/10/26/ajax...

and included the file dhtmlHistory.js where all the other javascript
files are.

but when a javascript function is called, it says 'error undefined
method 'this' in the dhtmlHistory.js library script.

'this' is a regularly used object in js...what gives?



Dominic

David Morton wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Jesse Farmer wrote:
>
>> I actually think AJAX can be used to unbreak the back button.  Many
>> times you're in a state where going back takes you to stale data.  This
>> can be dangerous in the case of submitting a form where there is the
>> potential for submitting the data twice, either by going back from the
>> "success" page or by hitting refresh on the "success" page, thereby
>> POSTing all over again.
>
> This is better solved by using redirects after a submit operation, then
> the
> update page is never available for a reload.
>
>
> - --
> David Morton
> Maia Mailguard                        - http://www.maiamailguard.com
> Morton Software Design and Consulting - http://www.dgrmm.net
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFD1raJSIxC85HZHLMRArJ1AJ0Tw9ZwwWWXJYvmqvnRlkv2VBhTEQCfWhkg
> +ZRGqYQA5mGcHBf9YHgIKl8=
> =oleG
> -----END PGP SIGNATURE-----
A6455ce99c86c3b36a1a3d232c0b399a?d=identicon&s=25 Dominic (Guest)
on 2006-11-11 20:40
oops, it was a typo, the js file loads, but gosh darnit, this seems
hard.

has anyone actually pulled this off adding partials to
DhtmlHistory.add() ?

and how would we go about this with the RoR structure and the use of
iframes?


Dominic wrote:
> I'm actually trying out this tutorial at
> 
http://www.onjava.com/pub/a/onjava/2005/10/26/ajax...
>
> and included the file dhtmlHistory.js where all the other javascript
> files are.
>
> but when a javascript function is called, it says 'error undefined
> method 'this' in the dhtmlHistory.js library script.
>
> 'this' is a regularly used object in js...what gives?
>
>
>
> Dominic
>
> David Morton wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Jesse Farmer wrote:
>>
>>> I actually think AJAX can be used to unbreak the back button.  Many
>>> times you're in a state where going back takes you to stale data.  This
>>> can be dangerous in the case of submitting a form where there is the
>>> potential for submitting the data twice, either by going back from the
>>> "success" page or by hitting refresh on the "success" page, thereby
>>> POSTing all over again.
>>
>> This is better solved by using redirects after a submit operation, then
>> the
>> update page is never available for a reload.
>>
>>
>> - --
>> David Morton
>> Maia Mailguard                        - http://www.maiamailguard.com
>> Morton Software Design and Consulting - http://www.dgrmm.net
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.2 (MingW32)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>> iD8DBQFD1raJSIxC85HZHLMRArJ1AJ0Tw9ZwwWWXJYvmqvnRlkv2VBhTEQCfWhkg
>> +ZRGqYQA5mGcHBf9YHgIKl8=
>> =oleG
>> -----END PGP SIGNATURE-----
This topic is locked and can not be replied to.