Search code examples
jqueryjquery-backstretch

jQuery Backstretch: next, prev methods


I'm building a site that uses Backstretch (super-handy by the way). I've seen a few examples of having specific elements push to a slide, like so:

$("#cheers").click(function(e) {
    e.preventDefault();
    $.backstretch('http://dl.dropbox.com/u/515046/www/cheers.jpg');
});

But has anyone had any experience with creating back/forward buttons (without having to specify a URL)? Looking in the source line 252 you'll see a next function, but I'm unsure of how to use that, binded with a standard click:

$("#cheers").click(function(e) {
    e.preventDefault();
    $.backstretch('http://dl.dropbox.com/u/515046/www/cheers.jpg');
});

Figured this would be useful as a subtle UI addition. Any pointers would be greatly appreciated. Thanks!


Solution

  • Here we go!

    $('#next').click(function(x) {
        x.preventDefault();
        $('body').data('backstretch').next();
    });
    $('#prev').click(function(x) {
        x.preventDefault();
        $('body').data('backstretch').prev();
    });