とにかくそれらをハイジャックすることを計画している場合は、URLにハッシュを追加する必要はありません。私のdiv#container内に通常のリンクがあり、この実装を使用するとすべてが正常に機能しているようです。
$("#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") {
console.log('hooray!');
// 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.
$(window).trigger("hashchange");