次のように、History.js の State.data にデータを設定できます。
var pushStateData = {};
function RetrieveSearchResults(type, url, searchData) {//, showResetButton,
controlToFocus, navDirection) {
pushStateData = {
SearchType : type,
SearchData : searchData,
};
RetrievePageResults(true, url, pushStateData);
}
function RetrievePageResults(pushNewUrl, url, pushStateData) {
navigationInProgress = true;
if (pushNewUrl) {
if (window.History) {
window.History.pushState(pushStateData, null, url);
}
$.get(url, pushStateData.SearchData, function (reply) {
$("#search-results").html(reply);
navigationInProgress = false;
});
}
Chrome で window.History.pushState ステートメントにブレークポイントを設定すると、pushStateData に目的の値があることがはっきりとわかります。
ただし、データを取得しようとすると:
$(window).bind("statechange", function (e) {
if (!navigationInProgress) {
var State = window.History.getState();
if (window.console && window.console.log) {
console.log("popstate", State, window.location.href);
}
RetrievePageResults(false, State.cleanUrl, State.data);
}
});
RetrievePageResults ステートメントにブレークポイントを設定すると、State.data オブジェクトに設定した値がなくなりました。State.data が定義されており、null ではありませんが、明白な値のない空のオブジェクトです。
ありがとう、スコット