I want to use the history.js plugin from jQuery. The code is:
// Global
var History = window.History;
$(document).ready(function() {
History.Adapter.bind(window, 'statechange', function(){
console.log('Yeeeeeeaah!');
});
window.History.pushState(null, null, '#42'); // Yeeeeeeaah!
});
function anotherFunc() {
window.History.pushState(null, null, '#test'); // Nothing happens
}
What’s wrong with the scope?
You did not execute
anotherFunc.Nothing is wrong with the scope, but you could’ve omitted the
var History = window.Historyand just usedHistory.