[Iliad] Bookmarking AJAX actions and fixing the back/forward buttons

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Iliad] Bookmarking AJAX actions and fixing the back/forward buttons

Nicolas Petton
Hi,

There is a new feature in recent versions of Iliad which allows you to
bookmark your AJAX app, using the hash (fragment) of the url - the hash
is the part after the #.

How to use it:

There are two steps to do it.

STEP ONE: Each anchor action can be associated with a hash parameter
with #action:hash:

For instance, in a blog app, you could write something like this:

e anchor
        action: [self showComments]
        hash: 'showComments'.

the action will be evaluated normally, but in addition the hash will be
added to the url.

STEP TWO: The next step is to retreive the state from the url, to update
state from normal requests too (when you give a link to someone or
refresh the page for example).

There is now a new route dedicated to the hash path, available in
Application>>hashRoute

You can use it like every other route:

self hashRoute next = 'showComments' ifTrue: [self showComments].

That's all!

This way, bookmarking AJAX state becomes easy, and you still think of
your control flow in term of actions.

Also, it will add entries to the history; so the back button will work
for your ajax apps :)

Best of all, it will continue to work without javascript enabled, like
Iliad did before, making normal requests, and just not using the hash.  

There is one drawback: the back button doesn't work for IE < 8 yet. I
still have to add a hack to iliad.js, but this will work too eventually.

Also, please note that this is very young code and may change in the
near future.

Cheers and sorry for the long post,

Nico

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

signature.asc (204 bytes) Download Attachment