Take the 2-minute tour ×

Currently, my understanding of jQuery BBQ is it requires me to use an href like href="#/stufff/123/13"

Problem with that is it requires me to add a # to all my URLs throughout the site which then means non-javascript browsers can't use the site...

My question, is there a way I can simply add a class to all HREFs I want deep linked? something like class="deep-link-it-please".... Ideas? It also creates a headache in Rails which uses link_to which does not support adding a hash # before the URL.. thanks

share|improve this question
It looks to me like the BBQ script does all that for you. All you need to do is run the script and leave your href links as you normally would. –  Mottie Oct 4 '10 at 4:34
I wish, that doesn't work. still need to add a # in front of links. Is there a class way to do it? –  AnApprentice Oct 4 '10 at 15:47
add comment

2 Answers

What about adding a hash to the links you want to hijax?

    $('.bbq-nav a').each(function(){
       var nice = $(this).attr('href');
       $(this).attr('href','#' + nice);
share|improve this answer
add comment

You shouldn't need to add the hash to your urls if you plan on hijacking them anyway. With normal links inside of my div#container and everything seems to be working fine using this implementation:

$("#container a").live('click', function(){
    var hrefRequested = $(this).attr( "href" );

    // Push this URL "state" onto the history hash.
    $.bbq.pushState({ url: hrefRequested });

    // Prevent the default click behavior.
    return false;

// Bind a callback that executes when document.location.hash changes.
$(window).bind( "hashchange", function(e) {
    var url = $.bbq.getState( "url" );

    // Used to make sure that when you back up to the page you came in on
    // you don't get an empty page.
    if ( url == undefined ) { url = window.location.href; }

    $('#content-container').load(url + ' #container', function(response, status, xhr) {
        if (status == "success") {

            // document.title = ;
            // document.location.href = hrefRequested;

            // return false;

        if (status == "error") {
            var msg = "Sorry but there was an error: ";
            $("#error").html(msg + xhr.status + " " + xhr.statusText);

// You probably want to actually do something useful here..

// Since the event is only triggered when the hash changes, we need
// to trigger the event now, to handle the hash the page may have
// loaded with.
share|improve this answer
add comment

Your Answer


