This example demonstrates how to use the Browser History Manager to remember which tabs have been visited with the TabView widget and dynamically update it when the user presses the browser's back/forward buttons.
Tab One Content
Tab Two Content
Tab Three Content
In our example, the TabView widget relies on the following markup:
This markup should be inserted right after the opening body
tag.
In our example, we need the Event Utility, DOM Utility, TabView Widget, and the Browser History Manager:
In our simple example, we have only one module, represented by the TabView widget. We will refer to this module using the identifier
"tabview". The state of the TabView module will be represented using the string "tab"
followed by the selected tab
index (e.g. "tab2"
if the third tab is selected)
Use the YAHOO.util.History.getBookmarkedState
method and default to the first tab:
Use the YAHOO.util.History.register
method, passing in the TabView module identifier, the initial state of the TabView
module, and the callback function that will be called when the state of the TabView module has changed:
onReady
method
Use the Browser History Manager onReady
method to instantiate the TabView widget. Also, retrieve the current
state of the TabView module, and use that state to select the right tab (the current state may be different from the initial
state under certain circumstances - see the User's Guide)
A new history entry must be added every time the user selects a tab. Use the TabView widget's activeTabChange
event handler (set to handleTabViewActiveTabChange
- see above):
Simply call YAHOO.util.History.initialize
, passing in the id of the input field and IFrame we inserted
in our static markup:
You can load the necessary JavaScript and CSS for this example from Yahoo's servers. Click here to load the YUI Dependency Configurator with all of this example's dependencies preconfigured.
Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings