YUILibrary - Open source JavaScript and CSS for building richly interactive software.
Fork YUI on GitHub
  • Home
  • Gallery
  • Forums
  • YUI 2
  • YUI 3
  • YUI Labs
  • YUI Compressor
  • More
  • Gallery Forums
  • Gallery Stats
  • Gallery Calendar
  • Register
  • Login

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • FAQ
  • Developer FAQ
  • Developer Guide
  • Module Setup

Tag Cloud

ericf caridy yui2 tivac plugin jafl lsmith node io nzakas adam foxxtrot davglass ajax slideshow form animation rgrove event jsonp port overlay jacobfogg apipkin skinnable widget

Context Navigation

    YUI Library is not responsible for bugs or support with this module. It is available as a free service. For support please contact the module owner with the provided links.

    History Lite (gallery-history-lite) on cdn

    Last Updated: 12/19/09
    + 4 -

    Ryan Grove

    YUI Developer

    See 2 more by this user.

    Featured Item

    Created: 10/30/09
    Last CDN Push: 12/15/09
    Build Tag: gallery-2009.12.15-22
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.0.0
    Free for use.

    History Lite is similar in purpose to the YUI Browser History module, but with a more flexible API, no initialization or markup requirements, limited IE6/7 support, and a much smaller footprint.

    The primary differences between History Lite and the BHM are:

    • You don't need to add any markup to the page (although, as a consequence, back/forward history is not maintained in IE6 and 7 after the user navigates away from the page).
    • You don't need to initialize the History Lite component. It's ready to use as soon as it's on the page.
    • You don't need to register history parameters before using them.
    • You may add parameters to the history state at any time, since there's no initialization step and no parameter registration requirement. This makes it easy for multiple discrete components to share the history state without having to be aware of one another's needs ahead of time.
    • Smaller code footprint than the BHM as a result of the minimal API and lack of IE6/7 support. This makes History Lite a good fit in situations where performance is critical (it's currently used on Yahoo! Search).
    • Tags:
    • ajax
    • history
    • rgrove
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    The sample below is a brief tour of the History Lite API, which consists of the add() and get() methods and the global history-lite:change event. Yes, that's the entire API!

    Note that you don't need to include the Console module in order to use History Lite; it's included here for demonstration purposes.

    Code Sample

    <script src="http://yui.yahooapis.com/3.1.0/build/yui/yui-min.js"></script>
    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2009.12.15-22'
    }).use('gallery-history-lite', 'console', function (Y) {
     
        // Create a logging console so we can watch the awesomeness happen.
        Y.one(document.body).addClass('yui-skin-sam');
        new Y.Console().render();
     
        // Listen for history changes.
        Y.on('history-lite:change', function (e) {
            // Properties on e.changed represent new or changed history parameters.
            Y.each(e.changed, function (value, name) {
                Y.log(name + ' changed to "' + value + '"', 'debug', 'history-lite');
            });
     
            // Properties on e.removed represent history parameters that have been
            // removed.
            Y.each(e.removed, function (value, name) {
                Y.log(name + ' was removed', 'debug', 'history-lite');
            });
     
            // The get() method returns the current value of the specified history
            // parameter. If you call get() without specifying a parameter name,
            // it'll return an object containing all current history parameters and
            // their values.
            Y.log('current value of foo is ' + Y.HistoryLite.get('foo'), 'debug', 'history-lite');
        });
     
        // Simulate some history change events (watch the browser's location bar and
        // the debug console to see what's happening).
        setTimeout(function () {
            // The add() method accepts an object containing key/value pairs of
            // history parameter names and values. Each call to add() creates a new
            // browser history entry.
            Y.HistoryLite.add({foo: 'bar', baz: 'quux'});
        }, 1000);
     
        setTimeout(function () {
            // The add() method will also accept a query string.
            Y.HistoryLite.add('foo=kittens');
        }, 2000);
     
        setTimeout(function () {
            // A null or undefined value causes that parameter to be removed from
            // the history state.
            Y.HistoryLite.add({foo: null, baz: 'monkeys'});
        }, 3000);
     
    });
     

    Forum Posts

    No forum posts for this module.

    YUI Projects
    • All YUI Downloads
    • YUI 2
    • YUI 3
    • YUI Doc
    • YUI Compressor
    • YUILibrary.com
    • YUI Build Tool
    • YUI PHP Loader
    YUI Labs
    • All YUI Labs Projects
    • Yeti
    Pages & Links
    • All YUI Downloads
    • Git FAQ
    • Graded Browser Support
    • Contribute to YUI
    • Forum Stats
    • Gallery Stats
    • YUI Calendar
    Contribute
    • Submit a Bug
    • Request a Feature
    • Write Code
    • Meet the Team
    Follow YUI
    • on GitHub
    • on Twitter
    • on FriendFeed
    • on Facebook
    • on IRC
    • YUI Blog
    • YUI Theater
    • YUI Forums

    © 2010 YUI Library - Site Credits