Hi,
I know of three gotchas with RSH (none of them specific to Prototype):
1. You _have_ to call `window.dhtmlHistory.create` from a script tag
in the `body` element of your page, because it uses `document.write`
(sadly) to write elements during the course of that call. I have it
right at the end of my `body` tag.
2. You _have_ to call `window.dhtmlHistory.initialize` from the window
`load` event or later, not earlier (for instance, not from
dom:loaded).
3. You _have_ to have a file called 'blank.html' alongside the HTML
file you're using rsh.js in (or edit rsh.js to change the name and/or
path of that file).
YMMV, but looking at an app where I used it and it seems to work okay,
I call this function from with the `body` tag:
function writeHistoryElements() {
window.dhtmlHistory.create({
toJSON: Object.toJSON,
fromJSON: function(s)
{
return s.evalJSON();
}
});
}
...and then this code one once `window.load` has fired:
var history = window.dhtmlHistory;
history.initialize();
history.addListener(historyChange);
if (history.isFirstLoad())
{
// Do anything you may want to do on the first load
}
Example:
http://pastie.org/1103706
I don't use the data feature, just the notification of hash changes --
I store all state I'm going to need in the hash or on the server, so
that all URLs are bookmarkable. I think the idea of the data stuff is
that you can cache stuff on the client, but I don't need that for this
app and the data stuff didn't seem to work very well cross-browser
(RSH hasn't been maintained in a while).
HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com
On Aug 19, 5:21 pm, JJS <[email protected]> wrote:
> Hello, I'm trying to get RSH (or anything that works for the back
> button problem) implemented with prototype. I've tried what it says in
> the usage instructions, and some other alternatives in the comments
> (http://code.google.com/p/reallysimplehistory/wiki/UsageInstructions),
> but I can't get this to work
>
> I'd appreciate it if something could write out the really simple
> history functions to put in, and a working ajax example where the
> history is recorded.
>
> Thank You
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.