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.
Junior M. (Guest)
on 2006-01-12 06:14
Hi Folks! I'm new in the forum and i have a doubt. The button back
function with the Ajax on Rails?  tks.
Dan S. (Guest)
on 2006-01-12 07: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
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
Dan S.
Technology Visionary - Technology Assessment - Documentation
"Looking at technology from every angle"
http://www.eclecticity.com
Jesse F. (Guest)
on 2006-01-12 07: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 F. <removed_email_address@domain.invalid>
University of Chicago - NSIT Web Services
AIM:    farmerje
Jabber: removed_email_address@domain.invalid
Phone:  (773)363-1058
Tyler K. (Guest)
on 2006-01-12 08: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
Steve L. (Guest)
on 2006-01-12 16:50
(Received via mailing list)
On Thursday 12 January 2006 12:44 am, Jesse F. 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 L.
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
Alex Y. (Guest)
on 2006-01-12 16:59
(Received via mailing list)
Steve L. 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...
Jesse F. (Guest)
on 2006-01-12 17:51
(Received via mailing list)
Steve L. 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 F. <removed_email_address@domain.invalid>
University of Chicago - NSIT Web Services
AIM:    farmerje
Jabber: removed_email_address@domain.invalid
Phone:  (773)363-1058
Roberto S. (Guest)
on 2006-01-12 18: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...
Jesse F. (Guest)
on 2006-01-12 18:30
(Received via mailing list)
Roberto S. 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 F. <removed_email_address@domain.invalid>
University of Chicago - NSIT Web Services
AIM:    farmerje
Jabber: removed_email_address@domain.invalid
Phone:  (773)363-1058
Jon S. (Guest)
on 2006-01-15 04:13
(Received via mailing list)
On 1/11/06, Junior Marçal <removed_email_address@domain.invalid> 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
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Jon S.
removed_email_address@domain.invalid
David M. (Guest)
on 2006-01-25 01:24
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jesse F. 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 M.
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-----
Dominic (Guest)
on 2006-11-11 04: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 M. wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Jesse F. 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 M.
> 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-----
Dominic (Guest)
on 2006-11-11 21: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 M. wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Jesse F. 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 M.
>> 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.