Plugins

The plugins site is currently in development.

We've been looking to provide a higher-quality, spam-free experience at the plugins site for some time, and a major error on our part forced us to shut down the current site before we could put the new one in place. We are developing a new site, and you can follow along with its development on GitHub. For more information about this transition, including steps you can take as a plugin author to prepare, please read our post about what's going on.

History Event


Tested with IE6/7, Firefox 3, Opera 9.6, Safari 3.1.1, Chrome 0.2

Adds a history event to jQuery. Allows dynamic pages to create page states and easily recall them when user navigation occurs (such as the back button).

$(function() {
    $('#status').history(function(e, currentHash, previousHash) {
        $(this).html('User navigated to: ' + currentHash);
    });

    $('#status').historyadd(function(e, currentHash, previousHash) {
        $(this).html('Navigation added: ' + currentHash);
    });

    $(window).history(function(e, hash) {
        //myCustomLoadFunction(hash);
    });

    $('#button').click(function() {
        $.history.add('item123');
    });

    $('#status').html('The initial location is: ' + $.history.getCurrent());
});

Need data storage?

$(function(){
    var textboxData = {};

    $('#textbox').historyadd(function(e, currentHash, previousHash) {
        textboxData[previousHash] = $(this).val();
    });

    $('#textbox').history(function(e, currentHash, previousHash) {
        $(this).val(textboxData[currentHash] || '');
    });
});

Downloads



4.8
Your rating: None Average: 4.8 (5 votes)