dsHistory example errors

6 views
Skip to first unread message

mau...@gmail.com

unread,
Feb 18, 2008, 4:26:27 PM2/18/08
to dshistory-discuss
Hello there...

I am trying to use the dsHistory librery to my site.
I copy the bookmark example from the wiki, and i have 2 errors.

On load I have "dsHistory.QueryVars has no properties" on line 24:

if (typeof dsHistory.QueryVars['Showing'] == 'string' && typeof
dsHistory.QueryVars['Hiding'] == 'string') {

And when i try to navigate:

"historyObject has no properties" on line 12:

if (!historyObject.calledFromHistory) {

I am using Mozila firefox.

my code ( it's just a copy of the example):

<body>
<script src="dshistory/dshistory.js"></script>

<div id="first-tab" onclick="showContent({contentToShow: 'first-
block-content', contentToHide: 'second-block-content'})">First tab</
div>
<div id="second-tab" onclick="showContent({contentToShow: 'second-
block-content', contentToHide: 'first-block-content'})">Second tab</
div>

<div id="first-block-content">First block content</div>
<div id="second-block-content" style="display: none;">Second block
content</div>

<script>
function showContent(contentObject, historyObject) {
if (!historyObject.calledFromHistory) {
dsHistory.setQueryVar('Showing', contentObject.contentToShow);
dsHistory.setQueryVar('Hiding', contentObject.contentToHide);
dsHistory.bindQueryVars(showContent, window,
contentObject); // this should be treated the same as addFunction as
the setQueryVar functions above really don't have any impact yet
// now, dsHistory.QueryVars['Showing'] =
contentObject.contentToShow;
// now, dsHistory.QueryVars['Hiding'] =
contentObject.contentToHide;
}

document.getElementById(contentObject.contentToShow).style.display
= 'block';
document.getElementById(contentObject.contentToHide).style.display
= 'none';
}

if (typeof dsHistory.QueryVars['Showing'] == 'string' && typeof
dsHistory.QueryVars['Hiding'] == 'string') {
showContent({contentToShow: dsHistory.QueryVars['Showing'],
contentToHide: dsHistory.QueryVars['Hiding']});
} else {
dsHistory.addFunction(showContent, window, {
contentToShow: 'first-block-content',
contentToHide: 'second-block-content'
});
}
</script>
</body>

tks.. hoping you can help me..

maui

amattie

unread,
Feb 22, 2008, 6:53:51 PM2/22/08
to dshistory-discuss
Maui,

It turns out that I made two mistakes while putting the examples
together. In the (bad) examples, there were two main sources of those
errors.

1) In both examples, the evaluation of historyObject.calledFromHistory
would fail when the historyObject parameter wasn't passed. Since that
parameter was never passed when the page would load, you'd always see
an error.
2) Additionally, as you mentioned, there was an error when trying to
evaluate historyObject.QueryVars. In the original code, the object
that is now QueryElements used to be QueryVars, and so I accidentally
put in the old object name rather than the new one.

I've fixed both of the examples and tested them out; they seem to work
fine. I'm really sorry about the errors that you did run into though.
Additionally, please feel free to check out the working demo linked
from the project's main page in order to see a more complex and full-
featured example of how you can use dsHistory.

Andrew
Reply all
Reply to author
Forward
0 new messages